From 77c8e66d5535f48d742b43207ab038d38c57cd7b Mon Sep 17 00:00:00 2001 From: Sally Maki Date: Fri, 31 Jan 2020 17:24:03 -0800 Subject: [PATCH 1/9] Create Vacate appeal stream, clean up tasks --- app/models/appeal.rb | 12 ++ app/models/decision_issue.rb | 2 +- app/models/decision_review.rb | 2 +- .../tasks/judge_sign_motion_to_vacate_task.rb | 21 --- app/models/tasks/judge_task.rb | 1 - app/models/tasks/straight_vacate_task.rb | 17 --- app/models/tasks/vacate_and_de_novo_task.rb | 17 --- .../tasks/vacate_and_readjudication_task.rb | 17 --- app/workflows/initial_tasks_factory.rb | 26 ++-- app/workflows/post_decision_motion_updater.rb | 85 ++++++------ client/app/queue/mtv/MTVJudgeDisposition.jsx | 8 +- client/constants/MOTION_TO_VACATE.json | 4 +- db/seeds.rb | 2 +- spec/factories/task.rb | 6 - .../intake/higher_level_review/edit_spec.rb | 2 +- .../intake/higher_level_review_spec.rb | 4 +- .../intake/supplemental_claim/edit_spec.rb | 2 +- spec/feature/queue/motion_to_vacate_spec.rb | 125 +----------------- spec/models/higher_level_review_spec.rb | 12 +- spec/models/intake_spec.rb | 2 +- .../post_decision_motion_updater_spec.rb | 84 +----------- 21 files changed, 97 insertions(+), 354 deletions(-) delete mode 100644 app/models/tasks/judge_sign_motion_to_vacate_task.rb delete mode 100644 app/models/tasks/straight_vacate_task.rb delete mode 100644 app/models/tasks/vacate_and_de_novo_task.rb delete mode 100644 app/models/tasks/vacate_and_readjudication_task.rb diff --git a/app/models/appeal.rb b/app/models/appeal.rb index 0c00af70516..5875cddf005 100644 --- a/app/models/appeal.rb +++ b/app/models/appeal.rb @@ -84,6 +84,18 @@ def type stream_type || "Original" end + def create_stream(stream_type) + create!(slice( + :veteran_file_number, + :legacy_opt_in_approved, + :veteran_is_not_claimant, + :docket_type, + :docket_number + ).merge(stream_type: stream_type)).tap do |stream| + stream.create_claimant!(participant_id: claimant.participant_id, payee_code: claimant.payee_code) + end + end + # Returns the most directly responsible party for an appeal when it is at the Board, # mirroring Legacy Appeals' location code in VACOLS def assigned_to_location diff --git a/app/models/decision_issue.rb b/app/models/decision_issue.rb index fb7c8a2fa2a..11d4b30f4f6 100644 --- a/app/models/decision_issue.rb +++ b/app/models/decision_issue.rb @@ -246,7 +246,7 @@ def create_remand_supplemental_claim! ) fail AppealDTAPayeeCodeError, decision_review.id unless dta_payee_code - sc.create_claimants!( + sc.create_claimant!( participant_id: decision_review.claimant_participant_id, payee_code: dta_payee_code ) diff --git a/app/models/decision_review.rb b/app/models/decision_review.rb index 72318dd38e2..8ee6ca68fc3 100644 --- a/app/models/decision_review.rb +++ b/app/models/decision_review.rb @@ -138,7 +138,7 @@ def start_review! end # Creates claimants for automatically generated decision reviews - def create_claimants!(participant_id:, payee_code:) + def create_claimant!(participant_id:, payee_code:) remove_claimants! claimants.create_without_intake!(participant_id: participant_id, payee_code: payee_code) end diff --git a/app/models/tasks/judge_sign_motion_to_vacate_task.rb b/app/models/tasks/judge_sign_motion_to_vacate_task.rb deleted file mode 100644 index c0357efcd7d..00000000000 --- a/app/models/tasks/judge_sign_motion_to_vacate_task.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class JudgeSignMotionToVacateTask < JudgeTask - def additional_available_actions(user) - actions = [Constants.TASK_ACTIONS.LIT_SUPPORT_PULAC_CERULLO.to_h] - - if assigned_to.is_a?(User) && FeatureToggle.enabled?(:review_motion_to_vacate, user: user) - actions.push(Constants.TASK_ACTIONS.JUDGE_CHECKOUT_PULAC_CERULLO_REMINDER.to_h) - end - - actions - end - - def self.label - COPY::JUDGE_SIGN_MOTION_TO_VACATE_TASK_LABEL - end - - def child_must_have_active_assignee? - false - end -end diff --git a/app/models/tasks/judge_task.rb b/app/models/tasks/judge_task.rb index 1af38e73507..aaf3bd823dc 100644 --- a/app/models/tasks/judge_task.rb +++ b/app/models/tasks/judge_task.rb @@ -7,7 +7,6 @@ # - JudgeDispatchReturnTasks # - JudgeAssignTasks # - JudgeAddressMotionToVacateTasks -# - JudgeSignMotionToVacateTasks class JudgeTask < Task def available_actions(user) diff --git a/app/models/tasks/straight_vacate_task.rb b/app/models/tasks/straight_vacate_task.rb deleted file mode 100644 index dad6d5c2b45..00000000000 --- a/app/models/tasks/straight_vacate_task.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class StraightVacateTask < DecidedMotionToVacateTask - class << self - def label - COPY::STRAIGHT_VACATE_TASK_LABEL - end - - def org(user) - team = JudgeTeam.for_judge(user.reload) - - fail(Caseflow::Error::NonexistentJudgeTeam, user_id: user.id) if team.nil? - - team - end - end -end diff --git a/app/models/tasks/vacate_and_de_novo_task.rb b/app/models/tasks/vacate_and_de_novo_task.rb deleted file mode 100644 index d92e4b8a796..00000000000 --- a/app/models/tasks/vacate_and_de_novo_task.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class VacateAndDeNovoTask < DecidedMotionToVacateTask - class << self - def label - COPY::VACATE_AND_DE_NOVO_TASK_LABEL - end - - def org(user) - team = JudgeTeam.for_judge(user.reload) - - fail(Caseflow::Error::NonexistentJudgeTeam, user_id: user.id) if team.nil? - - team - end - end -end diff --git a/app/models/tasks/vacate_and_readjudication_task.rb b/app/models/tasks/vacate_and_readjudication_task.rb deleted file mode 100644 index 44a928a4b10..00000000000 --- a/app/models/tasks/vacate_and_readjudication_task.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class VacateAndReadjudicationTask < DecidedMotionToVacateTask - class << self - def label - COPY::VACATE_AND_READJUDICATION_TASK_LABEL - end - - def org(user) - team = JudgeTeam.for_judge(user.reload) - - fail(Caseflow::Error::NonexistentJudgeTeam, user_id: user.id) if team.nil? - - team - end - end -end diff --git a/app/workflows/initial_tasks_factory.rb b/app/workflows/initial_tasks_factory.rb index 9db5840a3f7..d138b3cbc7b 100644 --- a/app/workflows/initial_tasks_factory.rb +++ b/app/workflows/initial_tasks_factory.rb @@ -8,9 +8,7 @@ def initialize(appeal) def create_root_and_sub_tasks! create_vso_tracking_tasks - ActiveRecord::Base.transaction do - create_subtasks! - end + create_subtasks! if appeal.Original? end private @@ -24,17 +22,19 @@ def create_vso_tracking_tasks end def create_subtasks! - distribution_task = DistributionTask.create!(appeal: @appeal, parent: @root_task) + ActiveRecord::Base.transaction do + distribution_task = DistributionTask.create!(appeal: @appeal, parent: @root_task) - if @appeal.evidence_submission_docket? - EvidenceSubmissionWindowTask.create!(appeal: @appeal, parent: distribution_task) - elsif @appeal.hearing_docket? - ScheduleHearingTask.create!(appeal: @appeal, parent: distribution_task) - else - vso_tasks = IhpTasksFactory.new(distribution_task).create_ihp_tasks! - # If the appeal is direct docket and there are no ihp tasks, - # then it is initially ready for distribution. - distribution_task.ready_for_distribution! if vso_tasks.empty? + if @appeal.evidence_submission_docket? + EvidenceSubmissionWindowTask.create!(appeal: @appeal, parent: distribution_task) + elsif @appeal.hearing_docket? + ScheduleHearingTask.create!(appeal: @appeal, parent: distribution_task) + else + vso_tasks = IhpTasksFactory.new(distribution_task).create_ihp_tasks! + # If the appeal is direct docket and there are no ihp tasks, + # then it is initially ready for distribution. + distribution_task.ready_for_distribution! if vso_tasks.empty? + end end end end diff --git a/app/workflows/post_decision_motion_updater.rb b/app/workflows/post_decision_motion_updater.rb index 719d619a023..7e6f06c8061 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -1,26 +1,41 @@ # frozen_string_literal: true +## +# The PostDecisionMotionUpdater validates and creates a PostDecisionMotion from the JudgeAddressMotionToVacateTask, +# and creates the subsequent tasks or appeal streams. + class PostDecisionMotionUpdater include ActiveModel::Model - attr_reader :task, :params + attr_reader :task, :params, :disposition, :instructions def initialize(task, params) @task = task @params = params + @disposition = @params[:disposition] + @instructions = @params[:instructions] end + delegate :appeal, to: :task + def process ActiveRecord::Base.transaction do - motion = create_motion - return unless motion + return unless post_decision_motion - create_new_tasks + create_new_tasks if denied_or_dismissed? + if grant_type? + vacate_stream = appeal.create_stream("Vacate") + create_new_stream_tasks(vacate_stream) + end end end private + def post_decision_motion + @post_decision_motion ||= create_motion + end + def create_motion motion = PostDecisionMotion.new( task: task, @@ -32,7 +47,7 @@ def create_motion motion.vacated_decision_issue_ids = params[:vacated_decision_issue_ids] elsif disposition == "granted" # For full grant, auto populate all decision issue IDs - motion.vacated_decision_issue_ids = task.appeal.decision_issues.map(&:id) + motion.vacated_decision_issue_ids = appeal.decision_issues.map(&:id) end unless motion.valid? @@ -44,8 +59,8 @@ def create_motion end def create_new_tasks - # We create an AbstractMotionToVacateTask as sibling to the judge task - # to serve as parent for all successive tasks. It is created when associated with + # We create an AbstractMotionToVacateTask as sibling to the JudgeAddressMotionToVacateTask + # to serve as parent for successive Denied or Dismissed tasks. It is created when associated with # the new task in order to pass responsibility for validation to child task abstract_task = create_abstract_task @@ -54,11 +69,7 @@ def create_new_tasks return end - if grant_type? - judge_sign_task = create_judge_sign_task(abstract_task) - end - - new_task = create_new_task((judge_sign_task || abstract_task)) + new_task = create_new_task(abstract_task) unless new_task.valid? errors.messages.merge!(new_task.errors.messages) @@ -71,37 +82,29 @@ def create_new_tasks def create_abstract_task AbstractMotionToVacateTask.new( - appeal: task.appeal, + appeal: appeal, parent: task.parent, - assigned_to: task.assigned_to + assigned_to: judge_user ) end def create_new_task(parent) task_class.new( - appeal: task.appeal, + appeal: appeal, parent: parent, - assigned_by: task.assigned_to, - assigned_to: assigned_to, - instructions: [params[:instructions]] + assigned_by: judge_user, + assigned_to: attorney_user, + instructions: [instructions]] ) end - def create_judge_sign_task(parent) - JudgeSignMotionToVacateTask.new( - appeal: task.appeal, - parent: parent, - assigned_to: task.assigned_to - ) - end + def create_new_stream_tasks(stream) + InitialTasksFactory.new(stream).create_root_and_sub_tasks! - def disposition - case params[:disposition] - when "partial" - "partially_granted" - else - params[:disposition] - end + jdrt = JudgeDecisionReviewTask.create!(appeal: stream, parent: stream.root_task, assigned_to: judge_user) + AttorneyTask.create!( + appeal: stream, parent: jdrt, assigned_by: judge_user, assigned_to: attorney_user, instructions: [instructions] + ) end def task_class @@ -109,30 +112,30 @@ def task_class end def task_type - grant_type? ? params[:vacate_type] : "#{params[:disposition]}_motion_to_vacate" + "#{disposition}_motion_to_vacate" end def grant_type? - %w[granted partial].include? params[:disposition] + %w[granted partially_granted].include? disposition end def denied_or_dismissed? %w[denied dismissed].include? disposition end - def assigned_to - @assigned_to ||= (denied_or_dismissed? ? prev_motions_attorney : User.find_by(id: params[:assigned_to_id])) + def judge_user + task.assigned_to + end + + def attorney_user + @attorney_user ||= (denied_or_dismissed? ? prev_motions_attorney : User.find_by(id: params[:assigned_to_id])) end def prev_motions_attorney - mtv_mail_task.assigned_to + task.parent.assigned_to end def prev_motions_attorney_or_org prev_motions_attorney.inactive? ? LitigationSupport.singleton : prev_motions_attorney end - - def mtv_mail_task - task.parent - end end diff --git a/client/app/queue/mtv/MTVJudgeDisposition.jsx b/client/app/queue/mtv/MTVJudgeDisposition.jsx index 000e200a164..437bc3566c0 100644 --- a/client/app/queue/mtv/MTVJudgeDisposition.jsx +++ b/client/app/queue/mtv/MTVJudgeDisposition.jsx @@ -39,7 +39,7 @@ const formatInstructions = ({ disposition, vacateType, hyperlink, instructions } switch (disposition) { case 'granted': - case 'partial': + case 'partially_granted': parts.push(`This will be a ${vacateTypeText(vacateType)}`); parts.push(instructions); break; @@ -53,7 +53,7 @@ const formatInstructions = ({ disposition, vacateType, hyperlink, instructions } return parts.join('\n'); }; -const grantTypes = ['granted', 'partial']; +const grantTypes = ['granted', 'partially_granted']; const dispositionStrings = { denied: 'denial', @@ -113,7 +113,7 @@ export const MTVJudgeDisposition = ({ !disposition || !instructions || (isGrantType() && !vacateType) || - (disposition === 'partial' && !issueIds.length) || + (disposition === 'partially_granted' && !issueIds.length) || (disposition === 'dismissed' && !hyperlink) ); }; @@ -140,7 +140,7 @@ export const MTVJudgeDisposition = ({ value={disposition} /> - {disposition && disposition === 'partial' && ( + {disposition && disposition === 'partially_granted' && ( setIssueIds(newIssueIds)} diff --git a/client/constants/MOTION_TO_VACATE.json b/client/constants/MOTION_TO_VACATE.json index 36e0ecd1f5c..963d880a12f 100644 --- a/client/constants/MOTION_TO_VACATE.json +++ b/client/constants/MOTION_TO_VACATE.json @@ -30,12 +30,12 @@ ], "PARTIAL_GRANT_OPTION": { "displayText": "Grant partial vacatur", - "value": "partial", + "value": "partially_granted", "help": "e.g. if you do not want to vacate all the issues the veteran is requesting" }, "DISPOSITION_TEXT": { "granted": "grant or partial vacatur", - "partial": "partial vacatur", + "partially_granted": "partial vacatur", "denied": "denial of all issues for vacatur", "dismissed": "dismissal" } diff --git a/db/seeds.rb b/db/seeds.rb index 35da62bf15e..1339a6a9cbb 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -713,7 +713,7 @@ def create_higher_level_reviews_and_supplemental_claims same_office: false, benefit_type: "compensation" ) - higher_level_review.create_claimants!( + higher_level_review.create_claimant!( participant_id: "5382910292", payee_code: "10" ) diff --git a/spec/factories/task.rb b/spec/factories/task.rb index e235b296d7f..e056b74fd75 100644 --- a/spec/factories/task.rb +++ b/spec/factories/task.rb @@ -554,11 +554,5 @@ assigned_by { create(:user, full_name: "Judge User", css_id: "JUDGE_1") } assigned_to { create(:user, full_name: "Motions Attorney", css_id: "LIT_SUPPORT_ATTY_1") } end - - factory :judge_sign_motion_to_vacate_task, class: JudgeSignMotionToVacateTask do - type { JudgeSignMotionToVacateTask.name } - appeal - association :parent, factory: :abstract_motion_to_vacate_task - end end end diff --git a/spec/feature/intake/higher_level_review/edit_spec.rb b/spec/feature/intake/higher_level_review/edit_spec.rb index 3e656af870c..1ad0f9abae6 100644 --- a/spec/feature/intake/higher_level_review/edit_spec.rb +++ b/spec/feature/intake/higher_level_review/edit_spec.rb @@ -74,7 +74,7 @@ end before do - higher_level_review.create_claimants!(participant_id: "5382910292", payee_code: "10") + higher_level_review.create_claimant!(participant_id: "5382910292", payee_code: "10") allow(Fakes::VBMSService).to receive(:create_contentions!).and_call_original allow(Fakes::VBMSService).to receive(:remove_contention!).and_call_original diff --git a/spec/feature/intake/higher_level_review_spec.rb b/spec/feature/intake/higher_level_review_spec.rb index c7e784b6443..4b5ae048548 100644 --- a/spec/feature/intake/higher_level_review_spec.rb +++ b/spec/feature/intake/higher_level_review_spec.rb @@ -1269,7 +1269,7 @@ def complete_higher_level_review context "with legacy_opt_in_approved" do let(:receipt_date) { Time.zone.today } - scenario "adding issues" do + fscenario "adding issues" do start_higher_level_review(veteran, legacy_opt_in_approved: true) visit "/intake/add_issues" @@ -1304,7 +1304,7 @@ def complete_higher_level_review date: (profile_date - untimely_days).mdY, legacy_issues: true ) - +binding.pry expect(page).to have_content("Does issue 3 match any of these VACOLS issues?") add_intake_rating_issue("None of these match") diff --git a/spec/feature/intake/supplemental_claim/edit_spec.rb b/spec/feature/intake/supplemental_claim/edit_spec.rb index e049767dfb5..b97428938a1 100644 --- a/spec/feature/intake/supplemental_claim/edit_spec.rb +++ b/spec/feature/intake/supplemental_claim/edit_spec.rb @@ -65,7 +65,7 @@ let(:contested_decision_issue) { nil } before do - supplemental_claim.create_claimants!(participant_id: "5382910292", payee_code: "10") + supplemental_claim.create_claimant!(participant_id: "5382910292", payee_code: "10") allow(Fakes::VBMSService).to receive(:create_contentions!).and_call_original diff --git a/spec/feature/queue/motion_to_vacate_spec.rb b/spec/feature/queue/motion_to_vacate_spec.rb index b14381f1d9a..4a4c5bfbb6b 100644 --- a/spec/feature/queue/motion_to_vacate_spec.rb +++ b/spec/feature/queue/motion_to_vacate_spec.rb @@ -192,8 +192,9 @@ expect(page).to have_content(COPY::JUDGE_ADDRESS_MOTION_TO_VACATE_TASK_LABEL) end - it "judge grants motion to vacate (vacate & readjudication)" do + fit "judge grants motion to vacate (vacate and readjudicate)" do address_motion_to_vacate(user: judge, appeal: appeal, judge_task: judge_address_motion_to_vacate_task) + binding.pry find("label[for=disposition_granted]").click find("label[for=vacate-type_vacate_and_readjudication]").click fill_in("instructions", with: judge_notes) @@ -211,19 +212,7 @@ expect(motion).to_not be_nil expect(motion.disposition).to eq("granted") - # Verify new task creation - instructions = format_judge_instructions( - notes: judge_notes, - disposition: "granted", - vacate_type: "vacate_and_readjudication" - ) - new_task = VacateAndReadjudicationTask.find_by(assigned_to: drafting_attorney) - expect(new_task).to_not be_nil - expect(new_task.label).to eq COPY::VACATE_AND_READJUDICATION_TASK_LABEL - expect(new_task.available_actions(motions_attorney)).to include( - Constants.TASK_ACTIONS.LIT_SUPPORT_PULAC_CERULLO.to_h - ) - expect(new_task.instructions.join("")).to eq(instructions) + # Verify new appeal stream is created end it "judge grants motion to vacate (straight vacate)" do @@ -245,19 +234,7 @@ expect(motion).to_not be_nil expect(motion.disposition).to eq("granted") - # Verify new task creation - instructions = format_judge_instructions( - notes: judge_notes, - disposition: "granted", - vacate_type: "straight_vacate" - ) - new_task = StraightVacateTask.find_by(assigned_to: drafting_attorney) - expect(new_task).to_not be_nil - expect(new_task.label).to eq COPY::STRAIGHT_VACATE_TASK_LABEL - expect(new_task.available_actions(motions_attorney)).to include( - Constants.TASK_ACTIONS.LIT_SUPPORT_PULAC_CERULLO.to_h - ) - expect(new_task.instructions.join("")).to eq(instructions) + # Verify new appeal stream is created end it "judge grants motion to vacate (vacate & de novo)" do @@ -281,19 +258,7 @@ expect(motion.vacated_decision_issue_ids.length).to eq(appeal.decision_issues.length) expect(motion.vacated_decision_issue_ids).to include(*appeal.decision_issues.map(&:id)) - # Verify new task creation - instructions = format_judge_instructions( - notes: judge_notes, - disposition: "granted", - vacate_type: "vacate_and_de_novo" - ) - new_task = VacateAndDeNovoTask.find_by(assigned_to: drafting_attorney) - expect(new_task).to_not be_nil - expect(new_task.label).to eq COPY::VACATE_AND_DE_NOVO_TASK_LABEL - expect(new_task.available_actions(motions_attorney)).to include( - Constants.TASK_ACTIONS.LIT_SUPPORT_PULAC_CERULLO.to_h - ) - expect(new_task.instructions.join("")).to eq(instructions) + # Verify new appeal stream is created end it "judge grants partial vacatur (vacate & readjudication)" do @@ -319,19 +284,7 @@ expect(motion.disposition).to eq("partially_granted") expect(motion.vacated_issues.length).to eq(issues_to_select.length) - # Verify new task creation - instructions = format_judge_instructions( - notes: judge_notes, - disposition: "partial", - vacate_type: "vacate_and_readjudication" - ) - new_task = VacateAndReadjudicationTask.find_by(assigned_to: drafting_attorney) - expect(new_task).to_not be_nil - expect(new_task.label).to eq COPY::VACATE_AND_READJUDICATION_TASK_LABEL - expect(new_task.available_actions(motions_attorney)).to include( - Constants.TASK_ACTIONS.LIT_SUPPORT_PULAC_CERULLO.to_h - ) - expect(new_task.instructions.join("")).to eq(instructions) + # Verify new appeal stream is created end it "judge denies motion to vacate" do @@ -433,72 +386,6 @@ end end - describe "JudgeSignMotionToVacateTask" do - let!(:judge_team) { JudgeTeam.create_for_judge(judge) } - let!(:drafting_attorney) { create(:user, full_name: "Drafty McDrafter") } - - let!(:orig_atty_task) do - create(:ama_attorney_task, :completed, - assigned_to: drafting_attorney, appeal: appeal, created_at: receipt_date + 1.day, parent: root_task) - end - let!(:judge_review_task) do - create(:ama_judge_decision_review_task, :completed, - assigned_to: judge, appeal: appeal, created_at: receipt_date + 3.days, parent: root_task) - end - let!(:vacate_motion_mail_task) do - create(:vacate_motion_mail_task, appeal: appeal, assigned_to: motions_attorney, parent: root_task) - end - let!(:judge_address_motion_to_vacate_task) do - create(:judge_address_motion_to_vacate_task, appeal: appeal, assigned_to: judge, parent: vacate_motion_mail_task) - end - let!(:abstract_motion_to_vacate_task) do - create(:abstract_motion_to_vacate_task, appeal: appeal, parent: vacate_motion_mail_task) - end - let!(:judge_sign_motion_to_vacate_task) do - create( - :judge_sign_motion_to_vacate_task, - appeal: appeal, - assigned_to: judge, - parent: abstract_motion_to_vacate_task - ) - end - - before do - create(:staff, :judge_role, sdomainid: judge.css_id) - lit_support_team.add_user(motions_attorney) - judge_team.add_user(drafting_attorney) - ["John Doe", "Jane Doe"].map do |name| - judge_team.add_user(create(:user, full_name: name)) - end - FeatureToggle.enable!(:review_motion_to_vacate) - - vacate_motion_mail_task.update(status: Constants.TASK_STATUSES.completed) - judge_address_motion_to_vacate_task.update(status: Constants.TASK_STATUSES.completed) - end - - after { FeatureToggle.disable!(:review_motion_to_vacate) } - - context "triggers PulacCerulloReminderModal" do - it "judge sends to dispatch" do - judge_send_to_dispatch(user: judge, appeal: appeal) - - find("label[for=hasCavc_no]").click - click_button(text: "Submit") - - expect(page).to have_content("Add decisions") - end - - it "judge sends to Lit Support for Pulac Cerullo" do - judge_send_to_dispatch(user: judge, appeal: appeal) - - find("label[for=hasCavc_yes]").click - click_button(text: "Submit") - - expect(page).to have_content(COPY::PULAC_CERULLO_MODAL_TITLE) - end - end - end - describe "Attorney Completes Denied / Dismissed Motion to Vacate Task" do let(:judge_team) { JudgeTeam.create_for_judge(judge) } let(:drafting_attorney) { create(:user, full_name: "Drafty McDrafter") } diff --git a/spec/models/higher_level_review_spec.rb b/spec/models/higher_level_review_spec.rb index b09fa89c279..29c7ebd4faf 100644 --- a/spec/models/higher_level_review_spec.rb +++ b/spec/models/higher_level_review_spec.rb @@ -136,7 +136,7 @@ it "returns claimant's participant ID" do higher_level_review.save! - higher_level_review.create_claimants!(participant_id: "12345", payee_code: "00") + higher_level_review.create_claimant!(participant_id: "12345", payee_code: "00") higher_level_review.save! higher_level_review.reload expect(subject).to eql("12345") @@ -144,8 +144,8 @@ it "returns new claimant's participant ID if replaced" do higher_level_review.save! - higher_level_review.create_claimants!(participant_id: "12345", payee_code: "00") - higher_level_review.create_claimants!(participant_id: "23456", payee_code: "00") + higher_level_review.create_claimant!(participant_id: "12345", payee_code: "00") + higher_level_review.create_claimant!(participant_id: "23456", payee_code: "00") higher_level_review.reload expect(subject).to eql("23456") end @@ -160,7 +160,7 @@ it "returns claimant's payee_code" do higher_level_review.save! - higher_level_review.create_claimants!(participant_id: "12345", payee_code: "10") + higher_level_review.create_claimant!(participant_id: "12345", payee_code: "10") higher_level_review.save! higher_level_review.reload expect(subject).to eql("10") @@ -168,8 +168,8 @@ it "returns new claimant's payee_code if replaced" do higher_level_review.save! - higher_level_review.create_claimants!(participant_id: "12345", payee_code: "10") - higher_level_review.create_claimants!(participant_id: "23456", payee_code: "11") + higher_level_review.create_claimant!(participant_id: "12345", payee_code: "10") + higher_level_review.create_claimant!(participant_id: "23456", payee_code: "11") higher_level_review.reload expect(subject).to eql("11") end diff --git a/spec/models/intake_spec.rb b/spec/models/intake_spec.rb index ac68f6d555b..9bb8dcdaa37 100644 --- a/spec/models/intake_spec.rb +++ b/spec/models/intake_spec.rb @@ -646,7 +646,7 @@ class AnotherTestIntake < Intake; end end before do - higher_level_review.create_claimants!(participant_id: "5382910292", payee_code: "10") + higher_level_review.create_claimant!(participant_id: "5382910292", payee_code: "10") end it "clears expired intakes and creates new intake" do diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index 1c49cf906aa..733de803afd 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -54,32 +54,6 @@ expect(task.reload.status).to eq Constants.TASK_STATUSES.completed abstract_task = AbstractMotionToVacateTask.find_by(parent: task.parent) - judge_sign_task = JudgeSignMotionToVacateTask.find_by(assigned_to: judge) - expect(judge_sign_task).to_not be nil - expect(judge_sign_task.parent).to eq abstract_task - - org_task = VacateAndReadjudicationTask.find_by(assigned_to_id: judge_team.id) - expect(org_task).to_not be nil - expect(org_task.parent).to eq judge_sign_task - - attorney_task = VacateAndReadjudicationTask.find_by(assigned_to_id: assigned_to_id) - expect(attorney_task).to_not be nil - expect(attorney_task.parent).to eq org_task - expect(attorney_task.assigned_by).to eq task.assigned_to - expect(attorney_task.status).to eq Constants.TASK_STATUSES.assigned - end - - it "should close org task if user task is completed" do - subject.process - - org_task = VacateAndReadjudicationTask.find_by(assigned_to_id: judge_team.id) - attorney_task = VacateAndReadjudicationTask.find_by(parent: org_task) - - attorney_task.update!(status: Constants.TASK_STATUSES.completed) - - org_task.reload - - expect(org_task.status).to eq Constants.TASK_STATUSES.completed end end @@ -90,33 +64,6 @@ subject.process expect(task.reload.status).to eq Constants.TASK_STATUSES.completed abstract_task = AbstractMotionToVacateTask.find_by(parent: task.parent) - - judge_sign_task = JudgeSignMotionToVacateTask.find_by(assigned_to: judge) - expect(judge_sign_task).to_not be nil - expect(judge_sign_task.parent).to eq abstract_task - - org_task = StraightVacateTask.find_by(assigned_to_id: judge_team.id) - expect(org_task).to_not be nil - expect(org_task.parent).to eq judge_sign_task - - attorney_task = StraightVacateTask.find_by(assigned_to_id: assigned_to_id) - expect(attorney_task).to_not be nil - expect(attorney_task.parent).to eq org_task - expect(attorney_task.assigned_by).to eq task.assigned_to - expect(attorney_task.status).to eq Constants.TASK_STATUSES.assigned - end - - it "should close org task if user task is completed" do - subject.process - - org_task = StraightVacateTask.find_by(assigned_to_id: judge_team.id) - attorney_task = StraightVacateTask.find_by(parent: org_task) - - attorney_task.update!(status: Constants.TASK_STATUSES.completed) - - org_task.reload - - expect(org_task.status).to eq Constants.TASK_STATUSES.completed end it "saves all decision issue IDs for full grant" do @@ -135,33 +82,6 @@ subject.process expect(task.reload.status).to eq Constants.TASK_STATUSES.completed abstract_task = AbstractMotionToVacateTask.find_by(parent: task.parent) - - judge_sign_task = JudgeSignMotionToVacateTask.find_by(assigned_to: judge) - expect(judge_sign_task).to_not be nil - expect(judge_sign_task.parent).to eq abstract_task - - org_task = VacateAndDeNovoTask.find_by(assigned_to_id: judge_team.id) - expect(org_task).to_not be nil - expect(org_task.parent).to eq judge_sign_task - - attorney_task = VacateAndDeNovoTask.find_by(assigned_to_id: assigned_to_id) - expect(attorney_task).to_not be nil - expect(attorney_task.parent).to eq org_task - expect(attorney_task.assigned_by).to eq task.assigned_to - expect(attorney_task.status).to eq Constants.TASK_STATUSES.assigned - end - - it "should close org task if user task is completed" do - subject.process - - org_task = VacateAndDeNovoTask.find_by(assigned_to_id: judge_team.id) - attorney_task = VacateAndDeNovoTask.find_by(parent: org_task) - - attorney_task.update!(status: Constants.TASK_STATUSES.completed) - - org_task.reload - - expect(org_task.status).to eq Constants.TASK_STATUSES.completed end end @@ -174,7 +94,7 @@ expect(subject.errors[:assigned_to].first).to eq "can't be blank" expect(task.reload.status).to eq Constants.TASK_STATUSES.in_progress expect(AbstractMotionToVacateTask.count).to eq 0 - expect(VacateAndDeNovoTask.count).to eq 0 + # Expect appeal stream to not be created end end @@ -187,7 +107,7 @@ expect(subject.errors[:vacate_type].first).to eq "is required for granted disposition" expect(task.reload.status).to eq Constants.TASK_STATUSES.in_progress expect(AbstractMotionToVacateTask.count).to eq 0 - expect(VacateAndDeNovoTask.count).to eq 0 + # Expect appeal stream to not be created end end end From 980a29f28042f890e1c8f8610f9b3572efbfc7a1 Mon Sep 17 00:00:00 2001 From: Sally Maki Date: Mon, 3 Feb 2020 13:28:31 -0800 Subject: [PATCH 2/9] Fix creating new appeal stream, add tests --- app/models/appeal.rb | 9 +++-- app/workflows/initial_tasks_factory.rb | 26 +++++++------- app/workflows/post_decision_motion_updater.rb | 6 ++-- client/app/queue/CaseTitle.jsx | 4 +-- .../intake/higher_level_review_spec.rb | 4 +-- spec/feature/queue/motion_to_vacate_spec.rb | 34 +++++++++++++++---- .../post_decision_motion_updater_spec.rb | 1 - 7 files changed, 52 insertions(+), 32 deletions(-) diff --git a/app/models/appeal.rb b/app/models/appeal.rb index 5875cddf005..4f08005761f 100644 --- a/app/models/appeal.rb +++ b/app/models/appeal.rb @@ -85,13 +85,12 @@ def type end def create_stream(stream_type) - create!(slice( + Appeal.create!(self.slice( + :receipt_date, :veteran_file_number, :legacy_opt_in_approved, - :veteran_is_not_claimant, - :docket_type, - :docket_number - ).merge(stream_type: stream_type)).tap do |stream| + :veteran_is_not_claimant + ).merge(stream_type: stream_type, stream_docket_number: docket_number)).tap do |stream| stream.create_claimant!(participant_id: claimant.participant_id, payee_code: claimant.payee_code) end end diff --git a/app/workflows/initial_tasks_factory.rb b/app/workflows/initial_tasks_factory.rb index d138b3cbc7b..65ecc19be14 100644 --- a/app/workflows/initial_tasks_factory.rb +++ b/app/workflows/initial_tasks_factory.rb @@ -8,7 +8,9 @@ def initialize(appeal) def create_root_and_sub_tasks! create_vso_tracking_tasks - create_subtasks! if appeal.Original? + ActiveRecord::Base.transaction do + create_subtasks! if @appeal.Original? + end end private @@ -22,19 +24,17 @@ def create_vso_tracking_tasks end def create_subtasks! - ActiveRecord::Base.transaction do - distribution_task = DistributionTask.create!(appeal: @appeal, parent: @root_task) + distribution_task = DistributionTask.create!(appeal: @appeal, parent: @root_task) - if @appeal.evidence_submission_docket? - EvidenceSubmissionWindowTask.create!(appeal: @appeal, parent: distribution_task) - elsif @appeal.hearing_docket? - ScheduleHearingTask.create!(appeal: @appeal, parent: distribution_task) - else - vso_tasks = IhpTasksFactory.new(distribution_task).create_ihp_tasks! - # If the appeal is direct docket and there are no ihp tasks, - # then it is initially ready for distribution. - distribution_task.ready_for_distribution! if vso_tasks.empty? - end + if @appeal.evidence_submission_docket? + EvidenceSubmissionWindowTask.create!(appeal: @appeal, parent: distribution_task) + elsif @appeal.hearing_docket? + ScheduleHearingTask.create!(appeal: @appeal, parent: distribution_task) + else + vso_tasks = IhpTasksFactory.new(distribution_task).create_ihp_tasks! + # If the appeal is direct docket and there are no ihp tasks, + # then it is initially ready for distribution. + distribution_task.ready_for_distribution! if vso_tasks.empty? end end end diff --git a/app/workflows/post_decision_motion_updater.rb b/app/workflows/post_decision_motion_updater.rb index 7e6f06c8061..cbac445e405 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -27,6 +27,8 @@ def process vacate_stream = appeal.create_stream("Vacate") create_new_stream_tasks(vacate_stream) end + + task.update(status: Constants.TASK_STATUSES.completed) end end @@ -76,8 +78,6 @@ def create_new_tasks return end new_task.save - - task.update(status: Constants.TASK_STATUSES.completed) end def create_abstract_task @@ -94,7 +94,7 @@ def create_new_task(parent) parent: parent, assigned_by: judge_user, assigned_to: attorney_user, - instructions: [instructions]] + instructions: [instructions] ) end diff --git a/client/app/queue/CaseTitle.jsx b/client/app/queue/CaseTitle.jsx index d25b0c14ba2..2e297fcfc41 100644 --- a/client/app/queue/CaseTitle.jsx +++ b/client/app/queue/CaseTitle.jsx @@ -57,8 +57,8 @@ class CaseTitle extends React.PureComponent { - - + + { veteranCaseListIsVisible ? 'Hide' : 'View' } all cases diff --git a/spec/feature/intake/higher_level_review_spec.rb b/spec/feature/intake/higher_level_review_spec.rb index 4b5ae048548..c7e784b6443 100644 --- a/spec/feature/intake/higher_level_review_spec.rb +++ b/spec/feature/intake/higher_level_review_spec.rb @@ -1269,7 +1269,7 @@ def complete_higher_level_review context "with legacy_opt_in_approved" do let(:receipt_date) { Time.zone.today } - fscenario "adding issues" do + scenario "adding issues" do start_higher_level_review(veteran, legacy_opt_in_approved: true) visit "/intake/add_issues" @@ -1304,7 +1304,7 @@ def complete_higher_level_review date: (profile_date - untimely_days).mdY, legacy_issues: true ) -binding.pry + expect(page).to have_content("Does issue 3 match any of these VACOLS issues?") add_intake_rating_issue("None of these match") diff --git a/spec/feature/queue/motion_to_vacate_spec.rb b/spec/feature/queue/motion_to_vacate_spec.rb index 4a4c5bfbb6b..578ccda2f67 100644 --- a/spec/feature/queue/motion_to_vacate_spec.rb +++ b/spec/feature/queue/motion_to_vacate_spec.rb @@ -192,9 +192,8 @@ expect(page).to have_content(COPY::JUDGE_ADDRESS_MOTION_TO_VACATE_TASK_LABEL) end - fit "judge grants motion to vacate (vacate and readjudicate)" do + it "judge grants motion to vacate (vacate and readjudicate)" do address_motion_to_vacate(user: judge, appeal: appeal, judge_task: judge_address_motion_to_vacate_task) - binding.pry find("label[for=disposition_granted]").click find("label[for=vacate-type_vacate_and_readjudication]").click fill_in("instructions", with: judge_notes) @@ -212,7 +211,7 @@ expect(motion).to_not be_nil expect(motion.disposition).to eq("granted") - # Verify new appeal stream is created + verify_vacate_stream("vacate_and_readjudication") end it "judge grants motion to vacate (straight vacate)" do @@ -234,7 +233,7 @@ expect(motion).to_not be_nil expect(motion.disposition).to eq("granted") - # Verify new appeal stream is created + verify_vacate_stream("straight_vacate") end it "judge grants motion to vacate (vacate & de novo)" do @@ -258,7 +257,7 @@ expect(motion.vacated_decision_issue_ids.length).to eq(appeal.decision_issues.length) expect(motion.vacated_decision_issue_ids).to include(*appeal.decision_issues.map(&:id)) - # Verify new appeal stream is created + verify_vacate_stream("vacate_and_de_novo") end it "judge grants partial vacatur (vacate & readjudication)" do @@ -284,7 +283,7 @@ expect(motion.disposition).to eq("partially_granted") expect(motion.vacated_issues.length).to eq(issues_to_select.length) - # Verify new appeal stream is created + verify_vacate_stream("vacate_and_readjudication") end it "judge denies motion to vacate" do @@ -444,6 +443,29 @@ end end + def verify_vacate_stream(vacate_type) + vacate_stream = Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "Vacate") + expect(vacate_stream).to_not be_nil + expect(vacate_stream.claimant.participant_id).to eq(appeal.claimant.participant_id) + + # Check Task structure + instructions = format_judge_instructions( + notes: judge_notes, + disposition: "granted", + vacate_type: vacate_type + ) + root_task = vacate_stream.root_task + jdrt = JudgeDecisionReviewTask.find_by(parent_id: root_task.id, assigned_to_id: judge.id) + attorney_task = AttorneyTask.find_by( + parent_id: jdrt.id, + assigned_to_id: drafting_attorney.id, + assigned_by_id: judge.id, + status: Constants.TASK_STATUSES.assigned, + instructions: [instructions] + ) + expect(attorney_task).to_not be_nil + end + def send_to_judge(user:, appeal:, motions_attorney_task:) User.authenticate!(user: user) visit "/queue/appeals/#{appeal.uuid}" diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index 733de803afd..42db3ff22cb 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -53,7 +53,6 @@ subject.process expect(task.reload.status).to eq Constants.TASK_STATUSES.completed abstract_task = AbstractMotionToVacateTask.find_by(parent: task.parent) - end end From ec66b31ea0af7c88a0492aa0f8d2c042bc14d961 Mon Sep 17 00:00:00 2001 From: Sally Maki Date: Mon, 3 Feb 2020 17:31:05 -0800 Subject: [PATCH 3/9] Incorporate AttorneyTask validation, add create_stream model test --- app/models/appeal.rb | 16 ++++--- app/workflows/post_decision_motion_updater.rb | 13 ++++- client/app/queue/CaseTitle.jsx | 4 +- .../post_decision_motions_controller_spec.rb | 35 +++++++++----- spec/feature/queue/motion_to_vacate_spec.rb | 34 ++++--------- spec/models/appeal_spec.rb | 19 ++++++++ .../post_decision_motion_updater_spec.rb | 48 +++++++++++++++---- 7 files changed, 111 insertions(+), 58 deletions(-) diff --git a/app/models/appeal.rb b/app/models/appeal.rb index 4f08005761f..d0beab01a09 100644 --- a/app/models/appeal.rb +++ b/app/models/appeal.rb @@ -85,13 +85,15 @@ def type end def create_stream(stream_type) - Appeal.create!(self.slice( - :receipt_date, - :veteran_file_number, - :legacy_opt_in_approved, - :veteran_is_not_claimant - ).merge(stream_type: stream_type, stream_docket_number: docket_number)).tap do |stream| - stream.create_claimant!(participant_id: claimant.participant_id, payee_code: claimant.payee_code) + ActiveRecord::Base.transaction do + Appeal.create!(self.slice( + :receipt_date, + :veteran_file_number, + :legacy_opt_in_approved, + :veteran_is_not_claimant + ).merge(stream_type: stream_type, stream_docket_number: docket_number)).tap do |stream| + stream.create_claimant!(participant_id: claimant.participant_id, payee_code: claimant.payee_code) + end end end diff --git a/app/workflows/post_decision_motion_updater.rb b/app/workflows/post_decision_motion_updater.rb index cbac445e405..bd4f64dbba4 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -28,6 +28,8 @@ def process create_new_stream_tasks(vacate_stream) end + return if errors.messages.any? + task.update(status: Constants.TASK_STATUSES.completed) end end @@ -102,9 +104,16 @@ 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) - AttorneyTask.create!( + attorney_task = AttorneyTask.new( appeal: stream, parent: jdrt, assigned_by: judge_user, assigned_to: attorney_user, instructions: [instructions] ) + + unless attorney_task.valid? + errors.messages.merge!(attorney_task.errors.messages) + return + end + + attorney_task.save end def task_class @@ -128,7 +137,7 @@ def judge_user end def attorney_user - @attorney_user ||= (denied_or_dismissed? ? prev_motions_attorney : User.find_by(id: params[:assigned_to_id])) + @attorney_user ||= denied_or_dismissed? ? prev_motions_attorney : User.find_by(id: params[:assigned_to_id]) end def prev_motions_attorney diff --git a/client/app/queue/CaseTitle.jsx b/client/app/queue/CaseTitle.jsx index 2e297fcfc41..d25b0c14ba2 100644 --- a/client/app/queue/CaseTitle.jsx +++ b/client/app/queue/CaseTitle.jsx @@ -57,8 +57,8 @@ class CaseTitle extends React.PureComponent { - - + + { veteranCaseListIsVisible ? 'Hide' : 'View' } all cases diff --git a/spec/controllers/post_decision_motions_controller_spec.rb b/spec/controllers/post_decision_motions_controller_spec.rb index 7be557f03ad..802cffdbe2d 100644 --- a/spec/controllers/post_decision_motions_controller_spec.rb +++ b/spec/controllers/post_decision_motions_controller_spec.rb @@ -31,13 +31,12 @@ end end - context "when the motion is valid" do - it "returns a 200 response" do + context "when there is no judge or attorney team" do + it "returns an error" do allow(controller).to receive(:verify_authentication).and_return(true) task = create_task_without_unnecessary_models assigned_to = user - judge_team.add_user(user) params = { disposition: "granted", @@ -45,30 +44,42 @@ vacate_type: "vacate_and_readjudication", instructions: "formatted instructions", assigned_to_id: assigned_to.id } + post :create, params: params - expect(response).to be_success - expect(flash[:success]).to be_present + body = JSON.parse(response.body) + expect(body["errors"]).to match_array( + [{"detail"=>"Assigned by has to be a judge, Assigned to has to be an attorney"}] + ) end end - context "when there is no judge team" do - it "raises NonexistentJudgeTeam error" do + context "when the motion is valid" do + let!(:attorney_staff) { create(:staff, :attorney_role, sdomainid: user.css_id) } + before do + allow(judge).to receive(:judge_in_vacols?).and_return(true) + allow_any_instance_of(PostDecisionMotionUpdater).to receive(:judge_user).and_return(judge) + end + + it "returns a 200 response" do allow(controller).to receive(:verify_authentication).and_return(true) task = create_task_without_unnecessary_models - assigned_to = user + + expect(task.assigned_to).to eq judge + + judge_team.add_user(user) params = { disposition: "granted", task_id: task.id, vacate_type: "vacate_and_readjudication", instructions: "formatted instructions", - assigned_to_id: assigned_to.id } + assigned_to_id: user.id } + post :create, params: params - expect do - post :create, params: params - end.to raise_error(Caseflow::Error::NonexistentJudgeTeam) + expect(response).to be_success + expect(flash[:success]).to be_present end end end diff --git a/spec/feature/queue/motion_to_vacate_spec.rb b/spec/feature/queue/motion_to_vacate_spec.rb index 578ccda2f67..4605eca4397 100644 --- a/spec/feature/queue/motion_to_vacate_spec.rb +++ b/spec/feature/queue/motion_to_vacate_spec.rb @@ -192,7 +192,7 @@ expect(page).to have_content(COPY::JUDGE_ADDRESS_MOTION_TO_VACATE_TASK_LABEL) end - it "judge grants motion to vacate (vacate and readjudicate)" do + it "judge grants motion to vacate (vacate & readjudication)" do address_motion_to_vacate(user: judge, appeal: appeal, judge_task: judge_address_motion_to_vacate_task) find("label[for=disposition_granted]").click find("label[for=vacate-type_vacate_and_readjudication]").click @@ -211,7 +211,8 @@ expect(motion).to_not be_nil expect(motion.disposition).to eq("granted") - verify_vacate_stream("vacate_and_readjudication") + visit_vacate_stream + binding.pry end it "judge grants motion to vacate (straight vacate)" do @@ -233,7 +234,7 @@ expect(motion).to_not be_nil expect(motion.disposition).to eq("granted") - verify_vacate_stream("straight_vacate") + visit_vacate_stream end it "judge grants motion to vacate (vacate & de novo)" do @@ -257,7 +258,7 @@ expect(motion.vacated_decision_issue_ids.length).to eq(appeal.decision_issues.length) expect(motion.vacated_decision_issue_ids).to include(*appeal.decision_issues.map(&:id)) - verify_vacate_stream("vacate_and_de_novo") + visit_vacate_stream end it "judge grants partial vacatur (vacate & readjudication)" do @@ -283,7 +284,7 @@ expect(motion.disposition).to eq("partially_granted") expect(motion.vacated_issues.length).to eq(issues_to_select.length) - verify_vacate_stream("vacate_and_readjudication") + visit_vacate_stream end it "judge denies motion to vacate" do @@ -443,27 +444,10 @@ end end - def verify_vacate_stream(vacate_type) + def visit_vacate_stream vacate_stream = Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "Vacate") - expect(vacate_stream).to_not be_nil - expect(vacate_stream.claimant.participant_id).to eq(appeal.claimant.participant_id) - - # Check Task structure - instructions = format_judge_instructions( - notes: judge_notes, - disposition: "granted", - vacate_type: vacate_type - ) - root_task = vacate_stream.root_task - jdrt = JudgeDecisionReviewTask.find_by(parent_id: root_task.id, assigned_to_id: judge.id) - attorney_task = AttorneyTask.find_by( - parent_id: jdrt.id, - assigned_to_id: drafting_attorney.id, - assigned_by_id: judge.id, - status: Constants.TASK_STATUSES.assigned, - instructions: [instructions] - ) - expect(attorney_task).to_not be_nil + visit "/queue/appeals/#{vacate_stream.uuid}" + expect(page).to have_content("Vacate") end def send_to_judge(user:, appeal:, motions_attorney_task:) diff --git a/spec/models/appeal_spec.rb b/spec/models/appeal_spec.rb index b033f47d941..cb35968ebb5 100644 --- a/spec/models/appeal_spec.rb +++ b/spec/models/appeal_spec.rb @@ -9,6 +9,25 @@ let!(:appeal) { create(:appeal) } # must be *after* Timecop.freeze + context "#create_stream" do + let(:stream_type) { "Vacate" } + let!(:appeal) { create(:appeal, number_of_claimants: 1) } + + subject { appeal.create_stream(stream_type) } + + it "creates a new 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(subject.reload.claimant.participant_id).to eq(appeal.claimant.participant_id) + end + end + context "includes PrintsTaskTree concern" do context "#structure" do let!(:root_task) { create(:root_task, appeal: appeal) } diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index 42db3ff22cb..95929e4413d 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -1,9 +1,12 @@ # frozen_string_literal: true describe PostDecisionMotionUpdater, :all_dbs do + include QueueHelpers + let(:lit_support_team) { LitigationSupport.singleton } let(:judge) { create(:user, full_name: "Judge User", css_id: "JUDGE_1") } - let(:attorney) { create(:user) } + let!(:attorney) { create(:user) } + let!(:attorney_staff) { create(:staff, :attorney_role, sdomainid: attorney.css_id) } let!(:judge_team) do JudgeTeam.create_for_judge(judge).tap { |jt| jt.add_user(attorney) } end @@ -19,7 +22,15 @@ end end let(:mtv_mail_task) { create(:vacate_motion_mail_task, appeal: appeal, assigned_to: motions_atty) } - let(:task) { create(:judge_address_motion_to_vacate_task, :in_progress, parent: mtv_mail_task, assigned_to: judge) } + let(:task) do + create( + :judge_address_motion_to_vacate_task, + :in_progress, + parent: mtv_mail_task, + assigned_to: judge, + appeal: appeal + ) + end let(:vacate_type) { nil } let(:disposition) { nil } let(:assigned_to_id) { nil } @@ -44,15 +55,15 @@ describe "#process" do context "when disposition is granted" do let(:disposition) { "granted" } - let(:assigned_to_id) { create(:user).id } + let(:assigned_to_id) { attorney.id } context "when vacate type is vacate and readjudication" do let(:vacate_type) { "vacate_and_readjudication" } - it "should create vacate and readjudication attorney task with correct structure" do + it "should create a vacate stream" do subject.process expect(task.reload.status).to eq Constants.TASK_STATUSES.completed - abstract_task = AbstractMotionToVacateTask.find_by(parent: task.parent) + verify_vacate_stream(vacate_type) end end @@ -62,7 +73,7 @@ it "should create straight vacate attorney task with correct structure" do subject.process expect(task.reload.status).to eq Constants.TASK_STATUSES.completed - abstract_task = AbstractMotionToVacateTask.find_by(parent: task.parent) + verify_vacate_stream(vacate_type) end it "saves all decision issue IDs for full grant" do @@ -80,7 +91,7 @@ it "should create vacate and de novo attorney task with correct structure" do subject.process expect(task.reload.status).to eq Constants.TASK_STATUSES.completed - abstract_task = AbstractMotionToVacateTask.find_by(parent: task.parent) + verify_vacate_stream(vacate_type) end end @@ -93,20 +104,18 @@ expect(subject.errors[:assigned_to].first).to eq "can't be blank" expect(task.reload.status).to eq Constants.TASK_STATUSES.in_progress expect(AbstractMotionToVacateTask.count).to eq 0 - # Expect appeal stream to not be created end end context "when vacate type is missing" do let(:vacate_type) { nil } - let(:assigned_to_id) { create(:user).id } + let(:assigned_to_id) { attorney.id } it "should not create an attorney task" do subject.process expect(subject.errors[:vacate_type].first).to eq "is required for granted disposition" expect(task.reload.status).to eq Constants.TASK_STATUSES.in_progress expect(AbstractMotionToVacateTask.count).to eq 0 - # Expect appeal stream to not be created end end end @@ -207,4 +216,23 @@ end end end + + def verify_vacate_stream(vacate_type) + vacate_stream = Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "Vacate") + + expect(vacate_stream).to_not be_nil + expect(vacate_stream.claimant.participant_id).to eq(appeal.claimant.participant_id) + + root_task = vacate_stream.root_task + jdrt = JudgeDecisionReviewTask.find_by(parent_id: root_task.id, assigned_to_id: judge.id) + attorney_task = AttorneyTask.find_by( + parent_id: jdrt.id, + assigned_to_id: attorney.id, + assigned_by_id: judge.id, + status: Constants.TASK_STATUSES.assigned, + instructions: [instructions] + ) + + expect(attorney_task).to_not be_nil + end end From 88bbf9d377b6633c9c71bf558fe08a47b844cdf9 Mon Sep 17 00:00:00 2001 From: Sally Maki Date: Mon, 3 Feb 2020 17:40:15 -0800 Subject: [PATCH 4/9] Code climate --- app/models/appeal.rb | 2 +- spec/controllers/post_decision_motions_controller_spec.rb | 2 +- spec/feature/queue/motion_to_vacate_spec.rb | 1 - spec/workflows/post_decision_motion_updater_spec.rb | 8 ++++---- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/models/appeal.rb b/app/models/appeal.rb index d0beab01a09..9170c5548bb 100644 --- a/app/models/appeal.rb +++ b/app/models/appeal.rb @@ -86,7 +86,7 @@ def type def create_stream(stream_type) ActiveRecord::Base.transaction do - Appeal.create!(self.slice( + Appeal.create!(slice( :receipt_date, :veteran_file_number, :legacy_opt_in_approved, diff --git a/spec/controllers/post_decision_motions_controller_spec.rb b/spec/controllers/post_decision_motions_controller_spec.rb index 802cffdbe2d..a034f1d9e98 100644 --- a/spec/controllers/post_decision_motions_controller_spec.rb +++ b/spec/controllers/post_decision_motions_controller_spec.rb @@ -49,7 +49,7 @@ body = JSON.parse(response.body) expect(body["errors"]).to match_array( - [{"detail"=>"Assigned by has to be a judge, Assigned to has to be an attorney"}] + [{ "detail" => "Assigned by has to be a judge, Assigned to has to be an attorney" }] ) end end diff --git a/spec/feature/queue/motion_to_vacate_spec.rb b/spec/feature/queue/motion_to_vacate_spec.rb index 4605eca4397..fbe2faac0a2 100644 --- a/spec/feature/queue/motion_to_vacate_spec.rb +++ b/spec/feature/queue/motion_to_vacate_spec.rb @@ -212,7 +212,6 @@ expect(motion.disposition).to eq("granted") visit_vacate_stream - binding.pry end it "judge grants motion to vacate (straight vacate)" do diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index 95929e4413d..162a31f2a2c 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -63,7 +63,7 @@ it "should create a vacate stream" do subject.process expect(task.reload.status).to eq Constants.TASK_STATUSES.completed - verify_vacate_stream(vacate_type) + verify_vacate_stream end end @@ -73,7 +73,7 @@ it "should create straight vacate attorney task with correct structure" do subject.process expect(task.reload.status).to eq Constants.TASK_STATUSES.completed - verify_vacate_stream(vacate_type) + verify_vacate_stream end it "saves all decision issue IDs for full grant" do @@ -91,7 +91,7 @@ it "should create vacate and de novo attorney task with correct structure" do subject.process expect(task.reload.status).to eq Constants.TASK_STATUSES.completed - verify_vacate_stream(vacate_type) + verify_vacate_stream end end @@ -217,7 +217,7 @@ end end - def verify_vacate_stream(vacate_type) + def verify_vacate_stream vacate_stream = Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "Vacate") expect(vacate_stream).to_not be_nil From 857d00ab65c36e095a3b7b074035b44f4973f2db Mon Sep 17 00:00:00 2001 From: Sally Maki Date: Mon, 3 Feb 2020 18:20:54 -0800 Subject: [PATCH 5/9] Fix front end test --- spec/feature/queue/motion_to_vacate_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/feature/queue/motion_to_vacate_spec.rb b/spec/feature/queue/motion_to_vacate_spec.rb index fbe2faac0a2..c317f5b1710 100644 --- a/spec/feature/queue/motion_to_vacate_spec.rb +++ b/spec/feature/queue/motion_to_vacate_spec.rb @@ -262,7 +262,7 @@ it "judge grants partial vacatur (vacate & readjudication)" do address_motion_to_vacate(user: judge, appeal: appeal, judge_task: judge_address_motion_to_vacate_task) - find("label[for=disposition_partial]").click + find("label[for=disposition_partially_granted]").click find("label[for=vacate-type_vacate_and_readjudication]").click fill_in("instructions", with: judge_notes) From d630e5b14def1cb4728577d78569a1573235f51f Mon Sep 17 00:00:00 2001 From: Sally Maki Date: Thu, 6 Feb 2020 17:23:59 -0800 Subject: [PATCH 6/9] Code limate, lowercase stream_type --- app/models/appeal.rb | 10 +++++----- app/workflows/initial_tasks_factory.rb | 2 +- app/workflows/post_decision_motion_updater.rb | 17 +++++++++++------ spec/feature/queue/motion_to_vacate_spec.rb | 2 +- spec/models/appeal_spec.rb | 2 +- .../post_decision_motion_updater_spec.rb | 2 +- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/app/models/appeal.rb b/app/models/appeal.rb index 9170c5548bb..37a0fd682bb 100644 --- a/app/models/appeal.rb +++ b/app/models/appeal.rb @@ -26,9 +26,9 @@ class Appeal < DecisionReview has_many :record_synced_by_job, as: :record enum stream_type: { - "Original": "Original", - "Vacate": "Vacate", - "De Novo": "De Novo" + "original": "original", + "vacate": "vacate", + "de_novo": "de_novo" } before_save :set_stream_docket_number_and_stream_type @@ -81,7 +81,7 @@ def ui_hash end def type - stream_type || "Original" + stream_type&.titlecase || "Original" end def create_stream(stream_type) @@ -447,7 +447,7 @@ def set_stream_docket_number_and_stream_type if receipt_date && persisted? self.stream_docket_number ||= docket_number end - self.stream_type ||= type + self.stream_type ||= type.parameterize.underscore.to_sym end def maybe_create_translation_task diff --git a/app/workflows/initial_tasks_factory.rb b/app/workflows/initial_tasks_factory.rb index 65ecc19be14..2a1575886d1 100644 --- a/app/workflows/initial_tasks_factory.rb +++ b/app/workflows/initial_tasks_factory.rb @@ -9,7 +9,7 @@ def initialize(appeal) def create_root_and_sub_tasks! create_vso_tracking_tasks ActiveRecord::Base.transaction do - create_subtasks! if @appeal.Original? + create_subtasks! if @appeal.original? end end diff --git a/app/workflows/post_decision_motion_updater.rb b/app/workflows/post_decision_motion_updater.rb index bd4f64dbba4..ed93014e543 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -22,11 +22,8 @@ def process ActiveRecord::Base.transaction do return unless post_decision_motion - create_new_tasks if denied_or_dismissed? - if grant_type? - vacate_stream = appeal.create_stream("Vacate") - create_new_stream_tasks(vacate_stream) - end + handle_denial_or_dismissal + handle_grant return if errors.messages.any? @@ -62,7 +59,8 @@ def create_motion motion.save end - def create_new_tasks + def handle_denial_or_dismissal + return unless denied_or_dismissed? # We create an AbstractMotionToVacateTask as sibling to the JudgeAddressMotionToVacateTask # to serve as parent for successive Denied or Dismissed tasks. It is created when associated with # the new task in order to pass responsibility for validation to child task @@ -82,6 +80,13 @@ def create_new_tasks new_task.save end + def handle_grant + return unless grant_type? + + vacate_stream = appeal.create_stream("Vacate") + create_new_stream_tasks(vacate_stream) + end + def create_abstract_task AbstractMotionToVacateTask.new( appeal: appeal, diff --git a/spec/feature/queue/motion_to_vacate_spec.rb b/spec/feature/queue/motion_to_vacate_spec.rb index c317f5b1710..68a994d7c0b 100644 --- a/spec/feature/queue/motion_to_vacate_spec.rb +++ b/spec/feature/queue/motion_to_vacate_spec.rb @@ -444,7 +444,7 @@ end def visit_vacate_stream - vacate_stream = Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "Vacate") + vacate_stream = Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "vacate") visit "/queue/appeals/#{vacate_stream.uuid}" expect(page).to have_content("Vacate") end diff --git a/spec/models/appeal_spec.rb b/spec/models/appeal_spec.rb index cb35968ebb5..dcf6fdc4131 100644 --- a/spec/models/appeal_spec.rb +++ b/spec/models/appeal_spec.rb @@ -10,7 +10,7 @@ let!(:appeal) { create(:appeal) } # must be *after* Timecop.freeze context "#create_stream" do - let(:stream_type) { "Vacate" } + let(:stream_type) { "vacate" } let!(:appeal) { create(:appeal, number_of_claimants: 1) } subject { appeal.create_stream(stream_type) } diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index 162a31f2a2c..ce5f5b886cb 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -218,7 +218,7 @@ end def verify_vacate_stream - vacate_stream = Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "Vacate") + vacate_stream = Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "vacate") expect(vacate_stream).to_not be_nil expect(vacate_stream.claimant.participant_id).to eq(appeal.claimant.participant_id) From ed9610c536ae810725c51c8241af5ce6ee7490cd Mon Sep 17 00:00:00 2001 From: Sally Maki Date: Thu, 6 Feb 2020 17:38:22 -0800 Subject: [PATCH 7/9] Code climate --- app/workflows/post_decision_motion_updater.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/workflows/post_decision_motion_updater.rb b/app/workflows/post_decision_motion_updater.rb index ed93014e543..47728bdabb8 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -22,8 +22,7 @@ def process ActiveRecord::Base.transaction do return unless post_decision_motion - handle_denial_or_dismissal - handle_grant + denied_or_dismissed? ? handle_denial_or_dismissal : handle_grant return if errors.messages.any? @@ -60,10 +59,10 @@ def create_motion end def handle_denial_or_dismissal - return unless denied_or_dismissed? # We create an AbstractMotionToVacateTask as sibling to the JudgeAddressMotionToVacateTask # to serve as parent for successive Denied or Dismissed tasks. It is created when associated with # the new task in order to pass responsibility for validation to child task + return unless denied_or_dismissed? abstract_task = create_abstract_task unless abstract_task.valid? From 519a095ac35cdc005120dde7d69e4236c442a62e Mon Sep 17 00:00:00 2001 From: Sally Maki Date: Thu, 6 Feb 2020 17:51:14 -0800 Subject: [PATCH 8/9] Code climate --- app/workflows/post_decision_motion_updater.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/workflows/post_decision_motion_updater.rb b/app/workflows/post_decision_motion_updater.rb index 47728bdabb8..27f252f6d9b 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -22,7 +22,8 @@ def process ActiveRecord::Base.transaction do return unless post_decision_motion - denied_or_dismissed? ? handle_denial_or_dismissal : handle_grant + handle_denial_or_dismissal + handle_grant return if errors.messages.any? @@ -58,10 +59,10 @@ def create_motion motion.save end + # We create an AbstractMotionToVacateTask as sibling to the JudgeAddressMotionToVacateTask + # to serve as parent for successive Denied or Dismissed tasks. It is created when associated with + # the new task in order to pass responsibility for validation to child task def handle_denial_or_dismissal - # We create an AbstractMotionToVacateTask as sibling to the JudgeAddressMotionToVacateTask - # to serve as parent for successive Denied or Dismissed tasks. It is created when associated with - # the new task in order to pass responsibility for validation to child task return unless denied_or_dismissed? abstract_task = create_abstract_task From f7f3d4d6d5079fb25c700be85f70a54b5af7167b Mon Sep 17 00:00:00 2001 From: Sally Maki Date: Thu, 6 Feb 2020 18:44:29 -0800 Subject: [PATCH 9/9] update argument to create_stream to be lowercased --- app/workflows/post_decision_motion_updater.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/workflows/post_decision_motion_updater.rb b/app/workflows/post_decision_motion_updater.rb index 27f252f6d9b..dd6ef8cd82c 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -83,7 +83,7 @@ def handle_denial_or_dismissal def handle_grant return unless grant_type? - vacate_stream = appeal.create_stream("Vacate") + vacate_stream = appeal.create_stream(:vacate) create_new_stream_tasks(vacate_stream) end