Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only send AttorneyTasks back to judge assign #15493

Merged
merged 3 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/models/tasks/attorney_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ def send_back_to_judge_assign!(params = {})
end

def update_from_params(params, user)
update_params_will_cancel_task?(params) ? send_back_to_judge_assign!(params) : super(params, user)
update_params_will_cancel_attorney_task?(params) ? send_back_to_judge_assign!(params) : super(params, user)
end

private

def update_params_will_cancel_task?(params)
params[:status].eql?(Constants.TASK_STATUSES.cancelled)
def update_params_will_cancel_attorney_task?(params)
type == AttorneyTask.name && params[:status].eql?(Constants.TASK_STATUSES.cancelled)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change! Only AttyTasks go back to judge assign, not subclasses

end

def can_be_moved_by_user?(user)
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def self.find_first_task_or_create(appeal, task_type)
parent { create(:ama_judge_decision_review_task, appeal: appeal) }
end

factory :ama_judge_dispatch_return_to_attorney_task, class: AttorneyDispatchReturnTask do
factory :ama_attorney_dispatch_return_task, class: AttorneyDispatchReturnTask do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sneaky rename

parent { create(:ama_judge_decision_review_task, appeal: appeal) }
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/tasks/attorney_quality_review_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
let!(:judge_staff) { create(:staff, :judge_role, sdomainid: judge.css_id) }
let(:parent) { create(:ama_judge_dispatch_return_task) }
let!(:task) do
create(:ama_judge_dispatch_return_to_attorney_task, assigned_by: judge, assigned_to: atty, parent: parent)
create(:ama_attorney_dispatch_return_task, assigned_by: judge, assigned_to: atty, parent: parent)
end

subject { task.update!(status: Constants.TASK_STATUSES.cancelled) }
Expand Down
32 changes: 26 additions & 6 deletions spec/models/tasks/attorney_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,17 @@
context ".update_from_params" do
let(:judge) { create(:user, :with_vacols_judge_record) }
let(:attorney) { create(:user, :with_vacols_attorney_record) }
let(:judge_task) { create(:ama_judge_decision_review_task, assigned_to: judge) }
let(:attorney_task) do
create(:ama_attorney_task, assigned_to: attorney, assigned_by: judge, parent: judge_task)
end
let(:judge_task_type) { :ama_judge_decision_review_task }
let(:attorney_task_type) { :ama_attorney_task }
let(:judge_task) { create(judge_task_type, assigned_to: judge) }
let(:attorney_task) { create(attorney_task_type, assigned_to: attorney, assigned_by: judge, parent: judge_task) }
let(:params) { { status: Constants.TASK_STATUSES.completed } }

subject { attorney_task.update_from_params(params, attorney) }

context "when cancellation params are not provided" do
it "does not send_back_to_judge_assign!" do
tasks = attorney_task.update_from_params({ status: Constants.TASK_STATUSES.completed }, attorney)
tasks = subject

expect(tasks.first.type).to eq AttorneyTask.name
expect(tasks.first.status).to eq Constants.TASK_STATUSES.completed
Expand All @@ -169,8 +172,10 @@
end

context "when cancellation params are provided" do
let(:params) { { status: Constants.TASK_STATUSES.cancelled } }

it "calls send_back_to_judge_assign!" do
tasks = attorney_task.update_from_params({ status: Constants.TASK_STATUSES.cancelled }, attorney)
tasks = subject
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General refactoring


expect(tasks.first.type).to eq AttorneyTask.name
expect(tasks.first.status).to eq Constants.TASK_STATUSES.cancelled
Expand All @@ -184,6 +189,21 @@
expect(tasks.third.status).to eq Constants.TASK_STATUSES.assigned
expect(tasks.third.assigned_to).to eq judge
end

context "when the task is an attorney task subtype" do
let(:judge_task_type) { :ama_judge_dispatch_return_task }
let(:attorney_task_type) { :ama_attorney_dispatch_return_task }

it "does not send_back_to_judge_assign!" do
tasks = subject

expect(tasks.first.type).to eq AttorneyDispatchReturnTask.name
expect(tasks.first.status).to eq Constants.TASK_STATUSES.cancelled
expect(tasks.first.closed_at).to_not be nil

expect(tasks.first.parent.status).to eq Constants.TASK_STATUSES.assigned
end
end
end
end

Expand Down