-
Notifications
You must be signed in to change notification settings - Fork 19
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
Implements Backend of Case Movement for Blocked Cases #14957
Closed
lomky
wants to merge
8
commits into
kat/14260_backend_cancel_block_tasks_main
from
kat/14260_backend_cancel_block_tasks
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bf50161
Cancel descendants no longer cancels completed tasks
lomky 64c9d30
Implements Backend of Case Movement for Blocked Cases
lomky d924b9a
Lints the BlockedSpecialCaseMovement
lomky 031fca6
Refactors shared CaseMovement tests into shared file
lomky eb3f8ec
Names the shared examples thoughtfully
lomky 23c5c06
Creates Distribution Blocked seeds
lomky cbe38ce
Cleans up lint
lomky 831ce2a
Merge branch 'master' into kat/14260_backend_cancel_block_tasks
lomky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
app/models/tasks/special_case_movement/blocked_special_case_movement_task.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
## | ||
# Task to record on the appeal that the special case movement manually assigned the case outside of automatic | ||
# case distribution and intentionally cancelled any tasks that were blocking distribution | ||
|
||
class BlockedSpecialCaseMovementTask < SpecialCaseMovementTask | ||
private | ||
|
||
def distribute_to_judge | ||
Task.transaction do | ||
super | ||
cancel_tasks_blocking_distribution | ||
end | ||
end | ||
|
||
def cancel_tasks_blocking_distribution | ||
parent.cancel_descendants | ||
end | ||
|
||
def verify_appeal_distributable | ||
if DistributionTask.open.where(appeal: appeal).empty? | ||
fail(Caseflow::Error::IneligibleForBlockedSpecialCaseMovement, appeal_id: appeal.id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -474,6 +474,12 @@ | |
assigned_by { nil } | ||
end | ||
|
||
factory :extension_request_mail_task, class: ExtensionRequestMailTask do | ||
parent { create(:root_task, appeal: appeal) } | ||
assigned_to { MailTeam.singleton } | ||
assigned_by { nil } | ||
end | ||
|
||
Comment on lines
+477
to
+482
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I needed a MailTask type that should actually block distribution |
||
factory :judge_address_motion_to_vacate_task, class: JudgeAddressMotionToVacateTask do | ||
parent { create(:vacate_motion_mail_task, appeal: appeal) } | ||
end | ||
|
93 changes: 93 additions & 0 deletions
93
spec/models/tasks/special_case_movement/blocked_special_case_movement_task_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../special_case_movement_shared_examples" | ||
|
||
describe BlockedSpecialCaseMovementTask do | ||
describe ".create" do | ||
context "with Case Movement Team user" do | ||
let(:cm_user) { create(:user) } | ||
|
||
subject do | ||
BlockedSpecialCaseMovementTask.create!(appeal: appeal, | ||
assigned_to: cm_user, | ||
assigned_by: cm_user, | ||
parent: dist_task) | ||
end | ||
|
||
before do | ||
SpecialCaseMovementTeam.singleton.add_user(cm_user) | ||
end | ||
|
||
shared_examples "cancelled distribution children" do | ||
it "cancel any open distribution descendants" do | ||
dist_task = appeal.tasks.open.where(type: DistributionTask.name).first | ||
open_tasks = dist_task.descendants.select(&:open?) - [dist_task] | ||
expect { subject }.not_to raise_error | ||
open_tasks.each do |task| | ||
expect(task.reload.status).to eq(Constants.TASK_STATUSES.cancelled) | ||
end | ||
end | ||
end | ||
|
||
context "appeal ready for distribution" do | ||
let(:appeal) do | ||
create(:appeal, | ||
:with_post_intake_tasks, | ||
docket_type: Constants.AMA_DOCKETS.direct_review) | ||
end | ||
let(:dist_task) { appeal.tasks.active.where(type: DistributionTask.name).first } | ||
|
||
context "with no blocking tasks" do | ||
it_behaves_like "successful creation" | ||
end | ||
|
||
it_behaves_like "appeal has a nonblocking mail task" | ||
|
||
context "with (dispatch) blocking mail task" do | ||
before do | ||
# TODO: this _should_ not cancel after we finish | ||
# https://github.com/department-of-veterans-affairs/caseflow/issues/14057 | ||
# Distribution Blocking. Update this test to properly pass then! | ||
Comment on lines
+48
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO to be addressed in #14057 |
||
create(:congressional_interest_mail_task, | ||
appeal: appeal, | ||
parent: dist_task) | ||
end | ||
it_behaves_like "successful creation" | ||
it_behaves_like "cancelled distribution children" | ||
end | ||
|
||
context "with a (distribution) blocking mail task" do | ||
before do | ||
create(:extension_request_mail_task, | ||
appeal: appeal, | ||
parent: dist_task) | ||
end | ||
it_behaves_like "successful creation" | ||
it_behaves_like "cancelled distribution children" | ||
end | ||
end | ||
|
||
context "appeal at the evidence window state" do | ||
let(:appeal) do | ||
create(:appeal, | ||
:with_post_intake_tasks, | ||
docket_type: Constants.AMA_DOCKETS.evidence_submission) | ||
end | ||
let(:dist_task) { appeal.tasks.open.where(type: DistributionTask.name).first } | ||
|
||
context "with distribution task on_hold" do | ||
it_behaves_like "successful creation" | ||
it_behaves_like "cancelled distribution children" | ||
end | ||
|
||
it_behaves_like "wrong parent task type provided" | ||
end | ||
|
||
it_behaves_like "appeal past distribution" do | ||
let(:expected_error) { Caseflow::Error::IneligibleForBlockedSpecialCaseMovement } | ||
end | ||
end | ||
|
||
it_behaves_like "non Case Movement user provided" | ||
end | ||
end |
90 changes: 90 additions & 0 deletions
90
spec/models/tasks/special_case_movement_shared_examples.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# frozen_string_literal: true | ||
|
||
# Shared examples for both SpecialCaseMovementTask and BlockedSpecialCaseMovementTask | ||
|
||
shared_examples "successful creation" do | ||
it "should create the SCM task and JudgeAssign task" do | ||
expect { subject }.not_to raise_error | ||
scm_task = appeal.tasks.where(type: described_class.name).first | ||
expect(scm_task.status).to eq(Constants.TASK_STATUSES.completed) | ||
judge_task = appeal.tasks.open.where(type: JudgeAssignTask.name).first | ||
expect(judge_task.status).to eq(Constants.TASK_STATUSES.assigned) | ||
end | ||
end | ||
|
||
shared_examples "appeal has a nonblocking mail task" do | ||
before do | ||
create(:aod_motion_mail_task, | ||
appeal: appeal, | ||
parent: appeal.root_task) | ||
end | ||
it_behaves_like "successful creation" | ||
it "still has the open mail task" do | ||
aod_mail_task = AodMotionMailTask.where(appeal: appeal).first | ||
expect(aod_mail_task.open?).to eq(true) | ||
expect { subject }.not_to raise_error | ||
expect(aod_mail_task.reload.open?).to eq(true) | ||
end | ||
end | ||
|
||
shared_examples "wrong parent task type provided" do | ||
context "with the evidence window task as parent" do | ||
let(:evidence_window_task) { appeal.tasks.open.where(type: EvidenceSubmissionWindowTask.name).first } | ||
|
||
subject do | ||
described_class.create!(appeal: appeal, | ||
assigned_to: cm_user, | ||
assigned_by: cm_user, | ||
parent: evidence_window_task) | ||
end | ||
|
||
it "should error with wrong parent type" do | ||
expect { subject }.to raise_error(Caseflow::Error::InvalidParentTask) | ||
end | ||
end | ||
end | ||
|
||
shared_examples "appeal past distribution" do | ||
context "appeal at the judge already" do | ||
let(:appeal) do | ||
create(:appeal, | ||
:assigned_to_judge, | ||
docket_type: Constants.AMA_DOCKETS.direct_review) | ||
end | ||
let(:dist_task) { appeal.tasks.where(type: DistributionTask.name).first } | ||
|
||
subject do | ||
described_class.create!(appeal: appeal, | ||
assigned_to: cm_user, | ||
assigned_by: cm_user, | ||
parent: dist_task) | ||
end | ||
|
||
it "should error with appeal not distributable" do | ||
expect { subject }.to raise_error(expected_error) | ||
end | ||
end | ||
end | ||
|
||
shared_examples "non Case Movement user provided" do | ||
context "with a non-CaseMovement user" do | ||
let(:user) { create(:user) } | ||
let(:appeal) do | ||
create(:appeal, | ||
:with_post_intake_tasks, | ||
docket_type: Constants.AMA_DOCKETS.direct_review) | ||
end | ||
let(:dist_task) { appeal.tasks.active.where(type: DistributionTask.name).first } | ||
|
||
subject do | ||
described_class.create!(appeal: appeal, | ||
assigned_to: user, | ||
assigned_by: user, | ||
parent: dist_task) | ||
end | ||
|
||
it "should error with user error" do | ||
expect { subject }.to raise_error(Caseflow::Error::ActionForbiddenError) | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed to better reflect the why of what's being done in both cases