Skip to content

Commit

Permalink
adds the JudgeQualityReviewTask
Browse files Browse the repository at this point in the history
This is a new subclass for JudgeTasks created by Quality Review.

Connects #8107
  • Loading branch information
Tomas Apodaca committed Jan 2, 2019
1 parent b269b75 commit e1d4079
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 117 deletions.
1 change: 1 addition & 0 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class TasksController < ApplicationController
GenericTask: GenericTask,
QualityReviewTask: QualityReviewTask,
JudgeAssignTask: JudgeAssignTask,
JudgeQualityReviewTask: JudgeQualityReviewTask,
ScheduleHearingTask: ScheduleHearingTask,
MailTask: MailTask,
InformalHearingPresentationTask: InformalHearingPresentationTask
Expand Down
2 changes: 1 addition & 1 deletion app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def assign_to_judge_data
{
selected: root_task.children.find { |task| task.is_a?(JudgeTask) }.assigned_to,
options: users_to_options(Judge.list_all),
type: JudgeAssignTask.name
type: JudgeQualityReviewTask.name
}
end

Expand Down
27 changes: 27 additions & 0 deletions app/models/tasks/judge_quality_review_task.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class JudgeQualityReviewTask < JudgeTask
def baseline_actions
[Constants.TASK_ACTIONS.ASSIGN_TO_ATTORNEY.to_h, Constants.TASK_ACTIONS.MARK_COMPLETE.to_h]
end

def self.create_from_params(params, user)
Task.find(params[:parent_id])&.update!(status: :on_hold)
super(params, user)
end

def self.modify_params(params)
super(params).merge(type: JudgeQualityReviewTask.name)
end

def update_from_params(params, _current_user)
params[:instructions] = [instructions, params[:instructions]].flatten if params.key?(:instructions)

update_status(params.delete(:status)) if params.key?(:status)
update(params)

[self]
end

def label
COPY::JUDGE_QUALITY_REVIEW_TASK_LABEL
end
end
7 changes: 1 addition & 6 deletions app/models/tasks/judge_review_task.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
class JudgeReviewTask < JudgeTask
def baseline_actions
[
{
label: COPY::JUDGE_CHECKOUT_DISPATCH_LABEL,
value: "dispatch_decision/special_issues"
}
]
[Constants.TASK_ACTIONS.JUDGE_CHECKOUT.to_h]
end

def label
Expand Down
29 changes: 2 additions & 27 deletions app/models/tasks/judge_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ class JudgeTask < Task
include RoundRobinAssigner

def available_actions(_user)
actions = baseline_actions
actions << Constants.TASK_ACTIONS.MARK_COMPLETE.to_h if parent && parent.is_a?(QualityReviewTask)

actions
baseline_actions
end

def actions_available?(user)
Expand All @@ -16,17 +13,6 @@ def timeline_title
COPY::CASE_TIMELINE_JUDGE_TASK
end

def self.create_from_params(params, user)
new_task = super(params, user)

parent = Task.find(params[:parent_id]) if params[:parent_id]
if parent && parent.is_a?(QualityReviewTask)
parent.update!(status: :on_hold)
end

new_task
end

def self.modify_params(params)
super(params.merge(type: JudgeAssignTask.name))
end
Expand All @@ -35,19 +21,8 @@ def self.verify_user_can_create!(user)
QualityReview.singleton.user_has_access?(user) || super(user)
end

def update_from_params(params, _current_user)
return super unless parent && parent.is_a?(QualityReviewTask)

params["instructions"] = [instructions, params["instructions"]].flatten if params.key?("instructions")

update_status(params.delete("status")) if params.key?("status")
update(params)

[self]
end

def when_child_task_completed
update!(type: JudgeReviewTask.name)
update!(type: JudgeReviewTask.name) if type == JudgeAssignTask.name
super
end

Expand Down
1 change: 1 addition & 0 deletions client/COPY.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@

"JUDGE_ASSIGN_TASK_LABEL": "assign",
"JUDGE_REVIEW_TASK_LABEL": "review",
"JUDGE_QUALITY_REVIEW_TASK_LABEL": "quality review",

"CORRECT_REQUEST_ISSUES_LINK": "Correct issues"
}
2 changes: 1 addition & 1 deletion client/app/queue/AssignToAttorneyModalView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AssignToAttorneyModalView extends React.PureComponent<Props> {
) => {
const previousAssigneeId = tasks[0].assignedTo.id.toString();

if (tasks[0].label === 'assign') {
if (tasks[0].label === 'assign' || tasks[0].label === 'quality review') {
return this.props.initialAssignTasksToUser({
tasks,
assigneeId,
Expand Down
4 changes: 2 additions & 2 deletions client/app/queue/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ export const judgeReviewTasksSelector = createSelector(
[tasksByAssigneeCssIdSelector],
(tasks) => _.filter(tasks, (task: TaskWithAppeal) => {
if (task.appealType === 'Appeal') {
return task.label === 'review' &&
return (task.label === 'review' || task.label === 'quality review') &&
(task.status === TASK_STATUSES.in_progress || task.status === TASK_STATUSES.assigned);
}

// eslint-disable-next-line no-undefined
return [null, undefined, 'review'].includes(task.label);
return [null, undefined, 'review', 'quality review'].includes(task.label);
})
);

Expand Down
14 changes: 9 additions & 5 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ def create_qr_user
qr_user = User.create!(station_id: 101, css_id: "QR_USER", full_name: "QR User")
OrganizationsUser.add_user_to_organization(qr_user, QualityReview.singleton)

# Create two QR tasks. One assigned to the organization and one assigned to both the organization and a QR user.
# Create QR tasks; one assigned just to the QR org and three assigned both to the org and a QR user.
create_task_at_quality_review
create_task_at_quality_review(qr_user)
create_task_at_quality_review(qr_user, "Jane Michael", "Joan Ly")
create_task_at_quality_review(qr_user, "Cosette Zepeda", "Lian Arroyo")
create_task_at_quality_review(qr_user, "Huilen Concepcion", "Ilva Urrutia")
end

def create_aod_user
Expand Down Expand Up @@ -459,15 +461,17 @@ def create_task_at_attorney_review(appeal, judge, attorney)
)
end

def create_task_at_quality_review(qr_user = nil)
def create_task_at_quality_review(qr_user = nil, judge_name = nil, attorney_name = nil)
root_task = FactoryBot.create(:root_task)
appeal = root_task.appeal

judge = FactoryBot.create(:user)
judge = FactoryBot.create(:user, station_id: 101)
judge.update!(full_name: judge_name) if judge_name
FactoryBot.create(:staff, :judge_role, user: judge)
judge_task = JudgeAssignTask.create!(appeal: appeal, parent: root_task, assigned_to: judge)

atty = FactoryBot.create(:user)
atty = FactoryBot.create(:user, station_id: 101)
atty.update!(full_name: attorney_name) if attorney_name
FactoryBot.create(:staff, :attorney_role, user: atty)
atty_task_params = [{ appeal: appeal, parent_id: judge_task.id, assigned_to: atty, assigned_by: judge }]
atty_task = AttorneyTask.create_many_from_params(atty_task_params, judge).first
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/tasks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
FactoryBot.create(:staff, :attorney_role, sdomainid: attorney.css_id)
end

context "Attornet task" do
context "Attorney task" do
context "when current user is a judge" do
let(:ama_appeal) { create(:appeal) }
let(:ama_judge_task) { create(:ama_judge_task, assigned_to: user) }
Expand Down
5 changes: 5 additions & 0 deletions spec/factories/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
appeal { create(:appeal) }
end

factory :ama_judge_quality_review_task, class: JudgeQualityReviewTask do
type JudgeQualityReviewTask.name
appeal { create(:appeal) }
end

factory :ama_attorney_task do
type AttorneyTask.name
appeal { create(:appeal) }
Expand Down
90 changes: 83 additions & 7 deletions spec/feature/queue/ama_queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,17 @@

context "QR flow" do
let(:user_name) { "QR User" }
let!(:user) { FactoryBot.create(:user, roles: ["Reader"], full_name: user_name) }
let!(:qr_user) { FactoryBot.create(:user, roles: ["Reader"], full_name: user_name) }

let(:judge_user) { FactoryBot.create(:user, station_id: User::BOARD_STATION_ID, full_name: "Aaron Judge") }
let!(:judge_staff) { FactoryBot.create(:staff, :judge_role, user: judge_user) }

let(:attorney_user) { FactoryBot.create(:user, station_id: User::BOARD_STATION_ID, full_name: "Anna Attorney") }
let!(:attorney_staff) { FactoryBot.create(:staff, :attorney_role, user: attorney_user) }

let!(:quality_review_organization) { QualityReview.singleton }
let!(:other_organization) { Organization.create!(name: "Other organization", url: "other") }
let!(:appeal) { create(:appeal) }
let!(:appeal) { FactoryBot.create(:appeal) }

let!(:quality_review_task) do
create(
Expand All @@ -373,28 +376,30 @@
let!(:judge_task) { create(:ama_judge_task, parent: root_task, assigned_to: judge_user, status: :completed) }

before do
OrganizationsUser.add_user_to_organization(user, quality_review_organization)
OrganizationsUser.add_user_to_organization(qr_user, quality_review_organization)
# We expect all QR users to be attorneys. This matters because we serve different queue views on the frontend
# to attorneys.
FactoryBot.create(:staff, user: user)
User.authenticate!(user: user)
FactoryBot.create(:staff, user: qr_user)
User.authenticate!(user: qr_user)
end

scenario "return case to judge" do
# step "QR user visits the quality review organization page and assigns the task to themself"
visit quality_review_organization.path
click_on "Bob Smith"

find(".Select-control", text: "Select an action").click
find("div", class: "Select-option", text: "Assign to person").click

find(".Select-control", text: "Select a user").click
find("div", class: "Select-option", text: user.full_name).click
find("div", class: "Select-option", text: qr_user.full_name).click

fill_in "taskInstructions", with: "Review the quality"
click_on "Submit"

expect(page).to have_content("Task assigned to #{user_name}")

# step "QR user returns the case to a judge"
click_on "Caseflow"

click_on "Bob Smith"
Expand All @@ -407,15 +412,86 @@
click_on "Submit"
expect(page).to have_content("On hold (3)")

# step "judge reviews task and assigns a task to an attorney"
User.authenticate!(user: judge_user)

visit "/queue"

click_on "Bob Smith"

expect(page).to have_content(quality_review_instructions)

find(".Select-control", text: "Select an action").click
find("div", class: "Select-option", text: "Assign to attorney").click

find(".Select-control", text: "Select a user").click
find("div", class: "Select-option", text: "Other").click

find(".Select-control", text: "Select a user").click
first("div", class: "Select-option", text: attorney_user.full_name).click
click_on "Submit"

expect(page).to have_content("Assigned 1 case")

# step "attorney completes task and returns the case to the judge"
User.authenticate!(user: attorney_user)

visit "/queue"

click_on "Bob Smith"

find(".Select-control", text: "Select an action").click
find("div", class: "Select-option", text: "Decision ready for review").click

expect(page).to have_content("Select special issue(s)")

click_on "Continue"

expect(page).to have_content("Select Dispositions")

click_on "Continue"

expect(page).to have_content("Submit Draft Decision for Review")

fill_in "Document ID:", with: "1234"
click_on "Select a judge"
find(".Select-control", text: "Select a judge…").click
first("div", class: "Select-option", text: judge_user.full_name).click
fill_in "notes", with: "all done"

click_on "Continue"

expect(page).to have_content(
"Thank you for drafting Bob Smith's decision. It's been sent to #{judge_user.full_name} for review."
)

# step "judge completes task"
User.authenticate!(user: judge_user)

visit "/queue"

click_on "Switch to Assign Cases"
click_on "Bob Smith"

find("button", text: COPY::TASK_SNAPSHOT_VIEW_TASK_INSTRUCTIONS_LABEL).click
expect(page).to have_content(quality_review_instructions)

find(".Select-control", text: "Select an action").click
find("div", class: "Select-option", text: "Mark task complete").click

expect(page).to have_content("Mark this task \"complete\" and send the case back to")

click_on "Mark complete"

expect(page).to have_content("Bob Smith's case has been marked complete")

# step "QR reviews case"
User.authenticate!(user: qr_user)

visit "/queue"

click_on "Bob Smith"

expect(page).to have_content("Decision signed by judge")
end
end
end
4 changes: 2 additions & 2 deletions spec/feature/queue/task_queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
let!(:judge_team) { JudgeTeam.create_for_judge(judge_user) }

let!(:root_task) { FactoryBot.create(:root_task) }
let!(:appeal) { root_task.appeal }
let(:appeal) { root_task.appeal }

before do
User.authenticate!(user: judge_user)
Expand Down Expand Up @@ -308,7 +308,7 @@
assigned_by: qr_user
}]
end
let!(:judge_task) { JudgeAssignTask.create_many_from_params(judge_task_params, qr_user).first }
let!(:judge_task) { JudgeQualityReviewTask.create_many_from_params(judge_task_params, qr_user).first }

before do
visit("/queue/appeals/#{appeal.external_id}")
Expand Down

0 comments on commit e1d4079

Please sign in to comment.