Skip to content

Commit

Permalink
mbeard/APPEALS-64197 (#23656)
Browse files Browse the repository at this point in the history
* adds vlj_assign_to_attorney method to legacy_tasks_controller

* adds action, route, and updates to modal

* removes new method from legacytaskscontroller, updates queue repo method, and adds instructions param to judge case assignment to attorney

* removes other excess code

* updates to params

* adds feature toggle

* removes feature toggle

* adds instructions to queueactions

* updates instructions in JudgeCaseAssignmentToAttorney to always be an array

* updates to judgecaseassignmenttoattorney spec and queuerepository spec to include legacyassignmenttrackingtask

* updates to leadacytaskcontrollerspec to include instructions

* updates test instructions to empty array

* updates to test params

* Resets test to empty array

* re-adds params to instructions in test
  • Loading branch information
mbeardy authored Dec 5, 2024
1 parent 6dca4b7 commit 843dce7
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 17 deletions.
5 changes: 3 additions & 2 deletions app/models/judge_case_assignment_to_attorney.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class JudgeCaseAssignmentToAttorney
include ActiveModel::Model

attr_accessor :appeal_id, :assigned_to, :task_id, :assigned_by, :judge
attr_accessor :appeal_id, :assigned_to, :task_id, :assigned_by, :judge, :instructions

validates :assigned_by, :assigned_to, presence: true
validates :task_id, format: { with: /\A[0-9A-Z]+-[0-9]{4}-[0-9]{2}-[0-9]{2}\Z/i }, allow_blank: true
Expand All @@ -17,7 +17,8 @@ def assign_to_attorney!
assigned_by: assigned_by,
judge: judge || assigned_by,
attorney: assigned_to,
vacols_id: vacols_id
vacols_id: vacols_id,
instructions: Array.wrap(instructions)
)
end
end
Expand Down
10 changes: 9 additions & 1 deletion app/repositories/queue_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def aod_query(vacols_ids)
end
# :nocov:

def assign_case_to_attorney!(assigned_by:, judge:, attorney:, vacols_id:)
def assign_case_to_attorney!(assigned_by:, judge:, attorney:, vacols_id:, instructions:)
transaction do
unless VACOLS::Case.find(vacols_id).bfcurloc == judge.vacols_uniq_id
fail(Caseflow::Error::LegacyCaseAlreadyAssignedError,
Expand All @@ -125,6 +125,14 @@ def assign_case_to_attorney!(assigned_by:, judge:, attorney:, vacols_id:)

update_location_to_attorney(vacols_id, attorney)

LegacyAppealAssignmentTrackingTask.create!(
appeal: LegacyAppeal.find_by(vacols_id: vacols_id),
assigned_to: attorney,
assigned_by: assigned_by,
instructions: instructions,
status: Constants.TASK_STATUSES.completed
)

attrs = assign_to_attorney_attrs(vacols_id, attorney, assigned_by)

incomplete_record = incomplete_decass_record(vacols_id)
Expand Down
3 changes: 2 additions & 1 deletion client/app/queue/QueueActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,8 @@ export const initialAssignTasksToUser = ({
assigned_to_id: assigneeId,
type: 'JudgeCaseAssignmentToAttorney',
appeal_id: oldTask.appealId,
judge_id: previousAssigneeId
judge_id: previousAssigneeId,
instructions
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions spec/controllers/legacy_tasks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
let(:attorney) { create(:user) }
let(:user) { create(:user) }
let(:appeal) { create(:legacy_appeal, vacols_case: create(:case)) }
let(:instructions) { "Complete the review and draft a decision." }

before do
User.stub = user
@staff_user = create(:staff, role, user: user)
Expand Down Expand Up @@ -155,13 +157,15 @@
params = {
"appeal_id": @appeal.id,
"assigned_to_id": attorney.id,
"judge_id": user.id
"judge_id": user.id,
"instructions": instructions
}
allow(QueueRepository).to receive(:assign_case_to_attorney!).with(
assigned_by: current_user,
judge: user,
attorney: attorney,
vacols_id: @appeal.vacols_id
vacols_id: @appeal.vacols_id,
instructions: [instructions]
).and_return(true)

post :create, params: { tasks: params }
Expand All @@ -186,13 +190,15 @@
it "should be successful" do
params = {
"appeal_id": @appeal.id,
"assigned_to_id": attorney.id
"assigned_to_id": attorney.id,
"instructions": instructions
}
allow(QueueRepository).to receive(:assign_case_to_attorney!).with(
assigned_by: user,
judge: user,
attorney: attorney,
vacols_id: @appeal.vacols_id
vacols_id: @appeal.vacols_id,
instructions: [instructions]
).and_return(true)

post :create, params: { tasks: params }
Expand Down
44 changes: 41 additions & 3 deletions spec/models/judge_case_assignment_to_attorney_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
let(:attorney) { User.create(css_id: "CFS456", station_id: User::BOARD_STATION_ID) }
let(:vacols_case) { create(:case, bfcurloc: judge_staff.slogid) }
let(:appeal) { create(:legacy_appeal, vacols_case: vacols_case) }
let(:instructions) { "Complete the review and draft a decision." }

let!(:judge_staff) do
create(:staff, :judge_role, slogid: "BVABAWS", sdomainid: judge.css_id)
Expand All @@ -19,7 +20,8 @@
JudgeCaseAssignmentToAttorney.create(
appeal_id: appeal_id,
assigned_by: assigned_by,
assigned_to: assigned_to
assigned_to: assigned_to,
instructions: instructions
)
end

Expand All @@ -28,9 +30,45 @@
let(:assigned_by) { judge }
let(:assigned_to) { attorney }

it "it is successful" do
expect(QueueRepository).to receive(:assign_case_to_attorney!).once
it "is successful and passes instructions" do
expect(QueueRepository).to receive(:assign_case_to_attorney!).with(
hash_including(instructions: [instructions])
).once

expect(subject.valid?).to eq true
expect(subject.errors).to be_empty
end
end

context "when instructions are missing" do
let(:appeal_id) { appeal.id }
let(:assigned_by) { judge }
let(:assigned_to) { attorney }
let(:instructions) { nil }

it "is successful and uses an empty array for instructions" do
expect(QueueRepository).to receive(:assign_case_to_attorney!).with(
hash_including(instructions: [])
).once

expect(subject.valid?).to eq true
expect(subject.errors).to be_empty
end
end

context "when instructions are not an array" do
let(:appeal_id) { appeal.id }
let(:assigned_by) { judge }
let(:assigned_to) { attorney }
let(:instructions) { "Draft decision memo." }

it "normalizes instructions into an array" do
expect(QueueRepository).to receive(:assign_case_to_attorney!).with(
hash_including(instructions: ["Draft decision memo."])
).once

expect(subject.valid?).to eq true
expect(subject.errors).to be_empty
end
end

Expand Down
29 changes: 23 additions & 6 deletions spec/repositories/queue_repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
context ".assign_case_to_attorney!" do
before do
RequestStore.store[:current_user] = judge
allow(LegacyAppeal).to receive(:find_by).with(vacols_id: vacols_case.bfkey).and_return(legacy_appeal)
end

let(:judge) { User.create(css_id: "BAWS123", station_id: User::BOARD_STATION_ID) }
let(:attorney) { User.create(css_id: "SAMD456", station_id: User::BOARD_STATION_ID) }
let(:instructions) { "Complete the review and draft a decision." }
let(:vacols_case) { create(:case, bfcurloc: judge_staff.slogid) }
let(:legacy_appeal) { create(:legacy_appeal, vacols_case: vacols_case) }
def vacols_id
vacols_case.bfkey
end
Expand All @@ -34,7 +37,7 @@ def vacols_id
expect(VACOLS::Decass.where(defolder: vacols_case.bfkey).count).to eq 0

QueueRepository.assign_case_to_attorney!(
assigned_by: judge, judge: judge, attorney: attorney, vacols_id: vacols_id
assigned_by: judge, judge: judge, attorney: attorney, vacols_id: vacols_id, instructions: [instructions]
)

expect(vacols_case.reload.bfcurloc).to eq attorney_staff.slogid
Expand All @@ -48,6 +51,11 @@ def vacols_id
expect(decass.deadtim).to eq VacolsHelper.local_date_with_utc_timezone
expect(decass.dedeadline).to eq VacolsHelper.local_date_with_utc_timezone + 30.days
expect(decass.deassign).to eq VacolsHelper.local_time_with_utc_timezone

tracking_task = LegacyAppealAssignmentTrackingTask.last
expect(tracking_task).to be_present
expect(tracking_task.appeal).to eq legacy_appeal
expect(tracking_task.instructions).to eq [instructions]
end
end

Expand All @@ -59,12 +67,12 @@ def vacols_id
RequestStore.store[:current_user] = scm_user
end

it "should assign a case to attorney" do
it "should assign a case to attorney and create a tracking task" do
expect(vacols_case.bfcurloc).to eq judge_staff.slogid
expect(VACOLS::Decass.where(defolder: vacols_case.bfkey).count).to eq 0

QueueRepository.assign_case_to_attorney!(
assigned_by: scm_user, judge: judge, attorney: attorney, vacols_id: vacols_id
assigned_by: scm_user, judge: judge, attorney: attorney, vacols_id: vacols_id, instructions: [instructions]
)

expect(vacols_case.reload.bfcurloc).to eq attorney_staff.slogid
Expand All @@ -78,6 +86,15 @@ def vacols_id
expect(decass.deadtim).to eq VacolsHelper.local_date_with_utc_timezone
expect(decass.dedeadline).to eq VacolsHelper.local_date_with_utc_timezone + 30.days
expect(decass.deassign).to eq VacolsHelper.local_time_with_utc_timezone

tracking_task = LegacyAppealAssignmentTrackingTask.last
expect(tracking_task).to be_present
expect(tracking_task.appeal.vacols_id).to eq vacols_id
expect(tracking_task.assigned_to).to eq attorney
expect(tracking_task.assigned_by).to eq scm_user
expect(tracking_task.instructions).to eq [instructions]
expect(tracking_task.appeal).to eq legacy_appeal
expect(tracking_task.status).to eq Constants.TASK_STATUSES.completed
end
end

Expand All @@ -87,7 +104,7 @@ def vacols_id
it "should raise ActiveRecord::RecordNotFound" do
expect do
QueueRepository.assign_case_to_attorney!(
assigned_by: judge, judge: judge, attorney: attorney, vacols_id: vacols_id
assigned_by: judge, judge: judge, attorney: attorney, vacols_id: vacols_id, instructions: [instructions]
)
end.to raise_error(ActiveRecord::RecordNotFound)
end
Expand All @@ -99,7 +116,7 @@ def vacols_id

expect do
QueueRepository.assign_case_to_attorney!(
assigned_by: judge, judge: judge, attorney: attorney, vacols_id: vacols_id
assigned_by: judge, judge: judge, attorney: attorney, vacols_id: vacols_id, instructions: [instructions]
)
end.to raise_error(Caseflow::Error::LegacyCaseAlreadyAssignedError)
end
Expand All @@ -115,7 +132,7 @@ def vacols_id
deteam: "D5",
deprod: "DEV")
QueueRepository.assign_case_to_attorney!(
assigned_by: judge, judge: judge, attorney: attorney, vacols_id: vacols_id
assigned_by: judge, judge: judge, attorney: attorney, vacols_id: vacols_id, instructions: [instructions]
)
decass_results = VACOLS::Decass.where(defolder: vacols_case.bfkey)
expect(decass_results.count).to eq 1
Expand Down

0 comments on commit 843dce7

Please sign in to comment.