Skip to content

Commit

Permalink
Deepak/appeals 56223 (#23310)
Browse files Browse the repository at this point in the history
* update restrictions to add task

* update check_inbound_ops_team_user method

* update specs

* update specs
  • Loading branch information
SanthiParakal133 authored Oct 22, 2024
1 parent 47dcef5 commit cd5de70
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 7 deletions.
13 changes: 13 additions & 0 deletions app/models/tasks/cavc_correspondence_mail_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,35 @@ def available_actions(user)
[]
end

def self.create_from_params(params, user)
@assigned_by = user
super(params, user)
end

private

def cavc_appeal_stream
return if check_inbound_ops_team_user

if !appeal.cavc?
fail Caseflow::Error::ActionForbiddenError,
message: "CAVC Correspondence can only be added to Court Remand Appeals."
end
end

def appeal_at_cavc_lit_support
return if check_inbound_ops_team_user

if !open_cavc_task
fail Caseflow::Error::ActionForbiddenError,
message: "CAVC Correspondence can only be added while the appeal is with CAVC Litigation Support."
end
end

def check_inbound_ops_team_user
InboundOpsTeam.singleton.user_has_access?(assigned_by)
end

def open_cavc_task
appeal.open_cavc_task
end
Expand Down
3 changes: 2 additions & 1 deletion app/models/tasks/mail_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def create_from_params(params, user)
appeal: parent_task.appeal,
parent_id: parent_if_blocking_task(parent_task).id,
assigned_to: MailTeam.singleton,
instructions: [params[:instructions]].flatten
instructions: [params[:instructions]].flatten,
assigned_by: @assigned_by
)
end

Expand Down
39 changes: 39 additions & 0 deletions spec/feature/queue/correspondence/submit_intake_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,45 @@
expect(docket_assignee.class).to eq(ClerkOfTheBoard)
end
end

describe "with Cavc Correspondence Mail Task added" do
before do
visit_intake_form_step_2_with_appeals
existing_appeal_radio_options[:yes].click

using_wait_time(wait_time) do
within ".cf-case-list-table" do
page.all(".cf-form-checkbox").last.click
end
end

page.find("#button-addTasks").click
all("#reactSelectContainer")[0].click
find("div", exact_text: "CAVC Correspondence").click
find_by_id("content").fill_in with: "Correspondence Text"
click_button("Continue")
click_button("Submit")
click_button("Confirm")
using_wait_time(wait_time) do
expect(page).to have_content("You have successfully submitted a correspondence record")
end
end

it "creates CavcCorrespondenceMailTask for Appeal and Corespondence" do
expect(CavcCorrespondenceMailTask.all.count).to eq(2)
appeal = Appeal.find(CavcCorrespondenceMailTask.first.appeal_id)
correspondence_appeal = CorrespondenceAppeal.find_by(appeal_id: appeal.id)
expect(appeal.tasks.count { |e| e.instance_of?(CavcCorrespondenceMailTask) }).to eq(2)
expect(correspondence_appeal.tasks.count { |e| e.instance_of?(CavcCorrespondenceMailTask) }).to eq(1)
end

it "allows InboundOpsTeam user to assign CavcCorrespondenceMailTask to CavcLitigationSupport organization" do
assigner = User.find(CavcCorrespondenceMailTask.last.assigned_by_id)
assignee = Organization.find(CavcCorrespondenceMailTask.last.assigned_to_id)
expect(assigner.organizations).to include(InboundOpsTeam)
expect(assignee.class).to eq(CavcLitigationSupport)
end
end
end

describe "failure" do
Expand Down
15 changes: 9 additions & 6 deletions spec/models/tasks/cavc_correspondence_mail_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@
context "on a non-CAVC Appeal Stream" do
let(:root_task) { create(:root_task) }

it "fails to create the task" do
expect { subject }.to raise_error(Caseflow::Error::ActionForbiddenError)
it "create the task" do
subject
expect(CavcCorrespondenceMailTask.last.assigned_to).to eq(CavcLitigationSupport.singleton)
end
end

Expand All @@ -159,16 +160,18 @@
context "without a CAVC task" do
before { CavcTask.find_by(appeal: appeal).destroy }

it "fails to create the task" do
expect { subject }.to raise_error(Caseflow::Error::ActionForbiddenError)
it "create the task" do
subject
expect(CavcCorrespondenceMailTask.last.assigned_to).to eq(CavcLitigationSupport.singleton)
end
end

context "after the CAVC Lit Support work is complete" do
before { CavcTask.find_by(appeal: appeal).completed! }

it "fails to create the task" do
expect { subject }.to raise_error(Caseflow::Error::ActionForbiddenError)
it "create the task" do
subject
expect(CavcCorrespondenceMailTask.last.assigned_to).to eq(CavcLitigationSupport.singleton)
end
end

Expand Down

0 comments on commit cd5de70

Please sign in to comment.