Skip to content

Commit

Permalink
Motion to Vacate | Create "De Novo" appeal stream (#13471)
Browse files Browse the repository at this point in the history
Connects  #13336
  • Loading branch information
Sjones352 authored Feb 26, 2020
1 parent b49331c commit 04c211a
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 24 deletions.
5 changes: 2 additions & 3 deletions app/models/decision_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,9 @@ def associated_request_issue
request_issues.first
end

def create_contesting_request_issue!
vacate_appeal_stream = Appeal.find_by(stream_type: "vacate", stream_docket_number: decision_review.docket_number)
def create_contesting_request_issue!(appeal)
RequestIssue.find_or_create_by!(
decision_review: vacate_appeal_stream,
decision_review: appeal,
decision_review_type: decision_review_type,
contested_decision_issue_id: id,
contested_rating_issue_diagnostic_code: diagnostic_code,
Expand Down
2 changes: 1 addition & 1 deletion app/models/post_decision_motion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def request_issues_for_vacatur
end

def create_request_issues_for_vacatur
decision_issues_for_vacatur.map(&:create_contesting_request_issue!)
decision_issues_for_vacatur.map { |di| di.create_contesting_request_issue!(appeal) }
end

def vacated_decision_issues
Expand Down
5 changes: 5 additions & 0 deletions app/models/tasks/bva_dispatch_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def create_from_root_task(root_task)

def outcode(appeal, params, user)
if appeal.is_a?(Appeal)
if appeal.vacate? && appeal.vacate_type == "vacate_and_de_novo"
appeal.create_stream(:de_novo).tap do |de_novo_stream|
appeal.decision_issues.map { |di| di.create_contesting_request_issue!(de_novo_stream) }
end
end
AmaAppealDispatch.new(appeal: appeal, user: user, params: params).call
elsif appeal.is_a?(LegacyAppeal)
LegacyAppealDispatch.new(appeal: appeal, params: params).call
Expand Down
18 changes: 1 addition & 17 deletions spec/factories/post_decision_motions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,8 @@

FactoryBot.define do
factory :post_decision_motion do
appeal { create(:appeal) }
appeal { create(:appeal, stream_type: "vacate") }
disposition { "granted" }
vacate_type { "straight_vacate" }

before(:create) do |post_decision_motion|
appeal = post_decision_motion.appeal
next unless appeal.reload.decision_issues.empty?

3.times do |idx|
create(
:decision_issue,
:rating,
decision_review: appeal,
disposition: "denied",
description: "Decision issue description #{idx}",
decision_text: "decision issue"
)
end
end
end
end
17 changes: 17 additions & 0 deletions spec/models/appeal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@
)
expect(subject.reload.claimant.participant_id).to eq(appeal.claimant.participant_id)
end

context "for de_novo appeal stream" do
let(:stream_type) { "de_novo" }

it "creates a de_novo appeal stream with data from the original appeal" do
expect(subject).to have_attributes(
receipt_date: appeal.receipt_date,
veteran_file_number: appeal.veteran_file_number,
legacy_opt_in_approved: appeal.legacy_opt_in_approved,
veteran_is_not_claimant: appeal.veteran_is_not_claimant,
stream_docket_number: appeal.docket_number,
stream_type: stream_type
)
expect(Appeal.de_novo.find_by(stream_docket_number: appeal.docket_number)).to_not be_nil
expect(subject.reload.claimant.participant_id).to eq(appeal.claimant.participant_id)
end
end
end

context "includes PrintsTaskTree concern" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/post_decision_motion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
let(:post_decision_motion) do
create(
:post_decision_motion,
appeal: appeal,
appeal: vacate_stream,
task: task,
disposition: disposition,
vacate_type: vacate_type,
Expand Down
28 changes: 26 additions & 2 deletions spec/models/tasks/bva_dispatch_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@

describe ".outcode" do
let(:user) { create(:user) }
let(:root_task) { create(:root_task) }
let(:root_task) { create(:root_task, appeal: appeal) }
let(:appeal) { create(:appeal, stream_type: stream_type) }
let(:stream_type) { "original" }
let(:the_case) { create(:case) }
let!(:legacy_appeal) { create(:legacy_appeal, vacols_case: the_case) }
let(:citation_number) { "A18123456" }
Expand All @@ -71,7 +73,6 @@
allow(ProcessDecisionDocumentJob).to receive(:perform_later)

BvaDispatchTask.outcode(root_task.appeal.reload, params, user)

tasks = BvaDispatchTask.where(appeal: root_task.appeal, assigned_to: user)
expect(tasks.length).to eq(1)
task = tasks[0]
Expand Down Expand Up @@ -123,6 +124,29 @@
end
end

context "when de_novo appeal stream" do
let(:stream_type) { "vacate" }
let!(:post_decision_motion) do
create(:post_decision_motion,
appeal: appeal, vacate_type: "vacate_and_de_novo",
task: create(:task))
end

it "should create de_novo appeal stream" do
allow(ProcessDecisionDocumentJob).to receive(:perform_later)

BvaDispatchTask.outcode(root_task.appeal, params, user)
tasks = BvaDispatchTask.where(appeal: appeal, assigned_to: user)
expect(tasks.length).to eq(1)

de_novo_stream = Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "de_novo")

expect(de_novo_stream).to_not be_nil
request_issues = de_novo_stream.request_issues
expect(request_issues.size).to eq(appeal.decision_issues.size)
end
end

context "when decision_date is in the future" do
let(:decision_date) { 1.day.from_now }

Expand Down

0 comments on commit 04c211a

Please sign in to comment.