Skip to content

Commit

Permalink
Motion to Vacate | Create "De Novo" Task (#13551)
Browse files Browse the repository at this point in the history
Connects #13336
  • Loading branch information
Sjones352 authored Feb 28, 2020
1 parent 0752945 commit 6256e11
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 7 deletions.
5 changes: 0 additions & 5 deletions app/models/tasks/bva_dispatch_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ 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
1 change: 1 addition & 0 deletions app/workflows/ama_appeal_dispatch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def outcode_appeal
complete_dispatch_root_task!
close_request_issues_as_decided!
store_poa_participant_id
DeNovoStreamCreator.new(appeal).call
end

def create_decision_document_and_submit_for_processing!(params)
Expand Down
46 changes: 46 additions & 0 deletions app/workflows/de_novo_stream_creator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# frozen_string_literal: true

class DeNovoStreamCreator
def initialize(appeal)
@appeal = appeal
end

def call
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) }
create_new_stream_tasks(de_novo_stream)
end
end
end

private

attr_reader :appeal

def create_new_stream_tasks(stream)
InitialTasksFactory.new(stream).create_root_and_sub_tasks!

jdrt = JudgeDecisionReviewTask.create!(appeal: stream, parent: stream.root_task, assigned_to: judge_user)
attorney_task = AttorneyTask.new(
appeal: stream, parent: jdrt, assigned_by: judge_user, assigned_to: attorney_user
)

attorney_task.save
end

def judge_user
judge_task&.assigned_to
end

def attorney_user
return unless judge_task

task = judge_task.children.find { |attorney| attorney.is_a?(AttorneyTask) && attorney.completed? }
task.assigned_to
end

def judge_task
appeal.tasks.find { |task| task.is_a?(JudgeDecisionReviewTask) && task.completed? }
end
end
17 changes: 15 additions & 2 deletions spec/models/tasks/bva_dispatch_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
end
let!(:request_issue) { create(:request_issue, decision_review: root_task.appeal) }
let!(:di) { create(:decision_issue, decision_review: root_task.appeal, request_issues: [request_issue]) }
let!(:attorney) { create(:user) }
let(:judge) { create(:user, full_name: "Judge User", css_id: "JUDGE_1") }

before do
BvaDispatch.singleton.add_user(user)
Expand Down Expand Up @@ -126,10 +128,18 @@

context "when de_novo appeal stream" do
let(:stream_type) { "vacate" }
let!(:task) { create(:ama_judge_decision_review_task, appeal: appeal, assigned_to: judge) }
let!(:attorney_task) { create(:ama_attorney_task, parent: task, assigned_to: attorney, appeal: appeal) }
let!(:post_decision_motion) do
create(:post_decision_motion,
appeal: appeal, vacate_type: "vacate_and_de_novo",
task: create(:task))
appeal: appeal,
vacate_type: "vacate_and_de_novo",
task: task)
end

before do
task.update!(status: "completed")
attorney_task.update!(status: "completed")
end

it "should create de_novo appeal stream" do
Expand All @@ -144,6 +154,9 @@
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)

judge_task = JudgeDecisionReviewTask.find_by(assigned_to: judge, appeal: de_novo_stream)
expect(judge_task).to_not be_nil
end
end

Expand Down

0 comments on commit 6256e11

Please sign in to comment.