Skip to content

Commit

Permalink
Use paged tasks in task controller
Browse files Browse the repository at this point in the history
  • Loading branch information
hschallhorn committed May 11, 2020
1 parent dcdcb73 commit b0bf1be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def set_application
# GET /tasks?user_id=xxx&role=attorney
# GET /tasks?user_id=xxx&role=judge
def index
tasks = QueueForRole.new(user_role).create(user: user).tasks
tasks = user.use_task_pages_api? ? [] : QueueForRole.new(user_role).create(user: user).tasks
render json: { tasks: json_tasks(tasks), queue_config: queue_config }
end

Expand Down
19 changes: 19 additions & 0 deletions spec/controllers/tasks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,25 @@

expect(data.size).to be(1)
end

context "when using task pages api" do
before do
expect(QueueForRole).not_to receive(:new)
FeatureToggle.enable!(:user_queue_pagination)
end
after { FeatureToggle.disable!(:user_queue_pagination) }

it "gets tasks from task pager, not queue for role" do
get :index, params: { user_id: user.id, role: "unknown" }
expect(response.status).to eq 200

queue_for_role_tasks = JSON.parse(response.body)["tasks"]["data"]
expect(queue_for_role_tasks.size).to be(0)

paged_tasks = JSON.parse(response.body)["queue_config"]["tabs"].first["tasks"]
expect(paged_tasks.size).to be(1)
end
end
end

context "when a task is assignable" do
Expand Down

0 comments on commit b0bf1be

Please sign in to comment.