From 38b1d58c1c0d02481cb46ef34e527d7752530dc7 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Wed, 18 Dec 2019 12:41:44 -0800 Subject: [PATCH 01/30] added basic support for creating request issues from selected MTV decision issues --- app/workflows/post_decision_motion_updater.rb | 18 +++++++++++++ .../post_decision_motion_updater_spec.rb | 26 ++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/app/workflows/post_decision_motion_updater.rb b/app/workflows/post_decision_motion_updater.rb index e5576f76d57..c53431e6006 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -16,6 +16,7 @@ def process return unless motion create_new_tasks + create_request_issues end end @@ -92,6 +93,23 @@ def create_judge_sign_task(parent) ) end + def create_request_issues + params[:vacated_decision_issue_ids].map do |decision_issue_id| + prev_decision_issue = DecisionIssue.find(decision_issue_id) + RequestIssue.create!( + decision_review: prev_decision_issue.decision_review, + decision_review_type: prev_decision_issue.decision_review_type, + contested_decision_issue_id: prev_decision_issue.id, + contested_rating_issue_reference_id: prev_decision_issue.rating_issue_reference_id, + contested_rating_issue_profile_date: prev_decision_issue.rating_profile_date, + contested_issue_description: prev_decision_issue.description, + nonrating_issue_category: prev_decision_issue.nonrating_issue_category, + benefit_type: prev_decision_issue.benefit_type, + decision_date: prev_decision_issue.caseflow_decision_date + ) + end + end + def disposition case params[:disposition] when "partial" diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index c5c18e00c86..35785b7102c 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -1,20 +1,31 @@ # frozen_string_literal: true describe PostDecisionMotionUpdater, :all_dbs do - let!(:lit_support_team) { LitigationSupport.singleton } + let(:lit_support_team) { LitigationSupport.singleton } let(:judge) { create(:user, full_name: "Judge User", css_id: "JUDGE_1") } let(:attorney) { create(:user) } let!(:judge_team) do JudgeTeam.create_for_judge(judge).tap { |jt| jt.add_user(attorney) } end - let!(:motions_atty) { create(:user, full_name: "Motions attorney") } - let!(:mtv_mail_task) { create(:vacate_motion_mail_task, assigned_to: motions_atty) } + let(:motions_atty) { create(:user, full_name: "Motions attorney") } + let(:appeal) { create(:appeal) } + let(:orig_decision_issues) do + Array.new(3) do + create( + :decision_issue, + decision_review: appeal, + disposition: "denied" + ) + 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(:vacate_type) { nil } let(:disposition) { nil } let(:assigned_to_id) { nil } let(:hyperlink) { "https://va.gov/fake-link-to-file" } let(:instructions) { "formatted instructions from judge" } + let(:vacated_decision_issue_ids) { orig_decision_issues.map(&:id) } let(:params) do { vacate_type: vacate_type, @@ -71,6 +82,15 @@ expect(org_task.status).to eq Constants.TASK_STATUSES.completed end + + context "when vacated_decision_issue_ids are specified" do + let(:params) { super().merge(vacated_decision_issue_ids: vacated_decision_issue_ids) } + it "should create request issues" do + subject.process + appeal.reload + expect(appeal.request_issues.length).to eq 3 + end + end end context "when vacate type is straight vacate" do From 8d5c8f31fc18b8b010a1b05631efc1cad6780437 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Wed, 18 Dec 2019 13:19:08 -0800 Subject: [PATCH 02/30] only create request issues if disposition is grant type --- 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 c53431e6006..4554e72c1a8 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -16,7 +16,7 @@ def process return unless motion create_new_tasks - create_request_issues + create_request_issues if grant_type? end end From 1f4cea55d640d98788d5d557a423978948787f09 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Fri, 20 Dec 2019 09:35:37 -0800 Subject: [PATCH 03/30] moved creation of request issues to PostDecisionMotion model; adjusted tests accordingly; --- app/models/post_decision_motion.rb | 17 ++++++ app/workflows/post_decision_motion_updater.rb | 18 ------- spec/models/post_decision_motion_spec.rb | 52 ++++++++++++++++++- .../post_decision_motion_updater_spec.rb | 19 ------- 4 files changed, 68 insertions(+), 38 deletions(-) diff --git a/app/models/post_decision_motion.rb b/app/models/post_decision_motion.rb index 0c973c3b156..18303f3b60f 100644 --- a/app/models/post_decision_motion.rb +++ b/app/models/post_decision_motion.rb @@ -29,6 +29,23 @@ def vacated_issues DecisionIssue.find(vacated_decision_issue_ids) end + def create_request_issues + vacated_decision_issue_ids.map do |decision_issue_id| + prev_decision_issue = DecisionIssue.find(decision_issue_id) + RequestIssue.create!( + decision_review: prev_decision_issue.decision_review, + decision_review_type: prev_decision_issue.decision_review_type, + contested_decision_issue_id: prev_decision_issue.id, + contested_rating_issue_reference_id: prev_decision_issue.rating_issue_reference_id, + contested_rating_issue_profile_date: prev_decision_issue.rating_profile_date, + contested_issue_description: prev_decision_issue.description, + nonrating_issue_category: prev_decision_issue.nonrating_issue_category, + benefit_type: prev_decision_issue.benefit_type, + decision_date: prev_decision_issue.caseflow_decision_date + ) + end + end + private def vacate_type_is_present_if_granted diff --git a/app/workflows/post_decision_motion_updater.rb b/app/workflows/post_decision_motion_updater.rb index 4554e72c1a8..e5576f76d57 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -16,7 +16,6 @@ def process return unless motion create_new_tasks - create_request_issues if grant_type? end end @@ -93,23 +92,6 @@ def create_judge_sign_task(parent) ) end - def create_request_issues - params[:vacated_decision_issue_ids].map do |decision_issue_id| - prev_decision_issue = DecisionIssue.find(decision_issue_id) - RequestIssue.create!( - decision_review: prev_decision_issue.decision_review, - decision_review_type: prev_decision_issue.decision_review_type, - contested_decision_issue_id: prev_decision_issue.id, - contested_rating_issue_reference_id: prev_decision_issue.rating_issue_reference_id, - contested_rating_issue_profile_date: prev_decision_issue.rating_profile_date, - contested_issue_description: prev_decision_issue.description, - nonrating_issue_category: prev_decision_issue.nonrating_issue_category, - benefit_type: prev_decision_issue.benefit_type, - decision_date: prev_decision_issue.caseflow_decision_date - ) - end - end - def disposition case params[:disposition] when "partial" diff --git a/spec/models/post_decision_motion_spec.rb b/spec/models/post_decision_motion_spec.rb index 97837a02bed..ee04731c6ad 100644 --- a/spec/models/post_decision_motion_spec.rb +++ b/spec/models/post_decision_motion_spec.rb @@ -1,5 +1,55 @@ # frozen_string_literal: true RSpec.describe PostDecisionMotion, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + let(:lit_support_team) { LitigationSupport.singleton } + let(:judge) { create(:user, full_name: "Judge User", css_id: "JUDGE_1") } + let(:attorney) { create(:user) } + let!(:judge_team) do + JudgeTeam.create_for_judge(judge).tap { |jt| jt.add_user(attorney) } + end + let(:motions_atty) { create(:user, full_name: "Motions attorney") } + let(:appeal) { create(:appeal) } + let(:orig_decision_issues) do + Array.new(3) do + create( + :decision_issue, + decision_review: appeal, + disposition: "denied" + ) + 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(:vacate_type) { nil } + let(:disposition) { nil } + let(:assigned_to_id) { nil } + let(:hyperlink) { "https://va.gov/fake-link-to-file" } + let(:instructions) { "formatted instructions from judge" } + let(:vacated_decision_issue_ids) { orig_decision_issues.map(&:id) } + let(:post_decision_motion) do + create( + :post_decision_motion, + task: task, + disposition: disposition, + vacate_type: vacate_type, + vacated_decision_issue_ids: vacated_decision_issue_ids + ) + end + + before do + create(:staff, :judge_role, sdomainid: judge.reload.css_id) + lit_support_team.add_user(motions_atty) + end + + context "handles creation of request issues" do + let(:disposition) { "granted" } + let(:vacate_type) { "vacate_and_readjudication" } + + it "creates a request issue for every selected decision issue" do + expect(appeal.request_issues.length).to eq 0 + post_decision_motion.create_request_issues + appeal.reload + expect(appeal.request_issues.length).to eq 3 + end + end end diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index 35785b7102c..fc2354d2df6 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -9,15 +9,6 @@ end let(:motions_atty) { create(:user, full_name: "Motions attorney") } let(:appeal) { create(:appeal) } - let(:orig_decision_issues) do - Array.new(3) do - create( - :decision_issue, - decision_review: appeal, - disposition: "denied" - ) - 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(:vacate_type) { nil } @@ -25,7 +16,6 @@ let(:assigned_to_id) { nil } let(:hyperlink) { "https://va.gov/fake-link-to-file" } let(:instructions) { "formatted instructions from judge" } - let(:vacated_decision_issue_ids) { orig_decision_issues.map(&:id) } let(:params) do { vacate_type: vacate_type, @@ -82,15 +72,6 @@ expect(org_task.status).to eq Constants.TASK_STATUSES.completed end - - context "when vacated_decision_issue_ids are specified" do - let(:params) { super().merge(vacated_decision_issue_ids: vacated_decision_issue_ids) } - it "should create request issues" do - subject.process - appeal.reload - expect(appeal.request_issues.length).to eq 3 - end - end end context "when vacate type is straight vacate" do From 29af3f7d34c5efbcc858c767ba6d44d436ca2e38 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Fri, 20 Dec 2019 10:45:12 -0800 Subject: [PATCH 04/30] adjustments to post_decision_motion_updater_spec to allow tests re inactive atty to pass (ensure variables are created in necessary order) --- spec/workflows/post_decision_motion_updater_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index fc2354d2df6..d7934d4f3fc 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -196,6 +196,8 @@ end it "should still assign org task if prev atty is inactive" do + expect(task.status).to eq Constants.TASK_STATUSES.in_progress + motions_atty.update_status!(Constants.USER_STATUSES.inactive) subject.process @@ -242,6 +244,8 @@ end it "should still assign org task if prev atty is inactive" do + expect(task.status).to eq Constants.TASK_STATUSES.in_progress + motions_atty.update_status!(Constants.USER_STATUSES.inactive) subject.process From 63ba17f7a832e08c4f070ee0e2ce56de4f6af03d Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Fri, 20 Dec 2019 11:12:12 -0800 Subject: [PATCH 05/30] linting --- spec/workflows/post_decision_motion_updater_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index d7934d4f3fc..6ef1571abc1 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -245,7 +245,7 @@ it "should still assign org task if prev atty is inactive" do expect(task.status).to eq Constants.TASK_STATUSES.in_progress - + motions_atty.update_status!(Constants.USER_STATUSES.inactive) subject.process From c3a5296e33176418c530c7cb95c04b25960e4207 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Mon, 23 Dec 2019 10:55:40 -0500 Subject: [PATCH 06/30] we now save all MTV issue IDs for "granted" disposition --- client/app/queue/mtv/MTVJudgeDisposition.jsx | 7 +++++++ spec/feature/queue/motion_to_vacate_spec.rb | 2 ++ 2 files changed, 9 insertions(+) diff --git a/client/app/queue/mtv/MTVJudgeDisposition.jsx b/client/app/queue/mtv/MTVJudgeDisposition.jsx index a7e1e0fbb55..b2170c4f0d3 100644 --- a/client/app/queue/mtv/MTVJudgeDisposition.jsx +++ b/client/app/queue/mtv/MTVJudgeDisposition.jsx @@ -87,9 +87,16 @@ export const MTVJudgeDisposition = ({ vacate_type: vacateType }; + // Ensure we pass selected issue IDs for partial grant if (issueIds.length) { result.vacated_decision_issue_ids = issueIds; } + + // Select all issues if full grant + if (disposition === 'granted') { + result.vacated_decision_issue_ids = appeal.decisionIssues.map((issue) => issue.id); + } + if (attorneyId) { result.assigned_to_id = attorneyId; } diff --git a/spec/feature/queue/motion_to_vacate_spec.rb b/spec/feature/queue/motion_to_vacate_spec.rb index d93d6c571eb..37cb280d6fa 100644 --- a/spec/feature/queue/motion_to_vacate_spec.rb +++ b/spec/feature/queue/motion_to_vacate_spec.rb @@ -268,6 +268,8 @@ motion = PostDecisionMotion.find_by(task: judge_address_motion_to_vacate_task) expect(motion).to_not be_nil expect(motion.disposition).to eq("granted") + 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( From 80cf6b81c4bb2d5d6e35a10554c3fbae1004167e Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Tue, 24 Dec 2019 09:07:18 -0500 Subject: [PATCH 07/30] we now add all decision issue IDs for full grant in PostDecisionMotionUpdater rather than on frontend; additional fields saved in newly created request issues; --- app/models/post_decision_motion.rb | 8 ++++---- app/workflows/post_decision_motion_updater.rb | 3 +++ client/app/queue/mtv/MTVJudgeDisposition.jsx | 6 ------ spec/models/post_decision_motion_spec.rb | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/models/post_decision_motion.rb b/app/models/post_decision_motion.rb index 18303f3b60f..34500cd1442 100644 --- a/app/models/post_decision_motion.rb +++ b/app/models/post_decision_motion.rb @@ -29,9 +29,8 @@ def vacated_issues DecisionIssue.find(vacated_decision_issue_ids) end - def create_request_issues - vacated_decision_issue_ids.map do |decision_issue_id| - prev_decision_issue = DecisionIssue.find(decision_issue_id) + def create_request_issues_for_vacature + vacated_issues.map do |prev_decision_issue| RequestIssue.create!( decision_review: prev_decision_issue.decision_review, decision_review_type: prev_decision_issue.decision_review_type, @@ -41,7 +40,8 @@ def create_request_issues contested_issue_description: prev_decision_issue.description, nonrating_issue_category: prev_decision_issue.nonrating_issue_category, benefit_type: prev_decision_issue.benefit_type, - decision_date: prev_decision_issue.caseflow_decision_date + decision_date: prev_decision_issue.caseflow_decision_date, + veteran_participant_id: task.appeal.veteran.participant_id ) end end diff --git a/app/workflows/post_decision_motion_updater.rb b/app/workflows/post_decision_motion_updater.rb index e5576f76d57..8df289a145e 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -30,6 +30,9 @@ def create_motion if params.key?(:vacated_decision_issue_ids) 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) end unless motion.valid? diff --git a/client/app/queue/mtv/MTVJudgeDisposition.jsx b/client/app/queue/mtv/MTVJudgeDisposition.jsx index b2170c4f0d3..f3b5788740b 100644 --- a/client/app/queue/mtv/MTVJudgeDisposition.jsx +++ b/client/app/queue/mtv/MTVJudgeDisposition.jsx @@ -87,16 +87,10 @@ export const MTVJudgeDisposition = ({ vacate_type: vacateType }; - // Ensure we pass selected issue IDs for partial grant if (issueIds.length) { result.vacated_decision_issue_ids = issueIds; } - // Select all issues if full grant - if (disposition === 'granted') { - result.vacated_decision_issue_ids = appeal.decisionIssues.map((issue) => issue.id); - } - if (attorneyId) { result.assigned_to_id = attorneyId; } diff --git a/spec/models/post_decision_motion_spec.rb b/spec/models/post_decision_motion_spec.rb index ee04731c6ad..1bb658a20bf 100644 --- a/spec/models/post_decision_motion_spec.rb +++ b/spec/models/post_decision_motion_spec.rb @@ -47,7 +47,7 @@ it "creates a request issue for every selected decision issue" do expect(appeal.request_issues.length).to eq 0 - post_decision_motion.create_request_issues + post_decision_motion.create_request_issues_for_vacature appeal.reload expect(appeal.request_issues.length).to eq 3 end From b55570f5076b5027d46c68975135bdca445b84ec Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Tue, 24 Dec 2019 09:20:46 -0500 Subject: [PATCH 08/30] added test for PostDecisionMotionUpdater adding all vacated_decision_issue_ids for full grant --- .../post_decision_motion_updater_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index 6ef1571abc1..a9bdd04951c 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -9,6 +9,15 @@ end let(:motions_atty) { create(:user, full_name: "Motions attorney") } let(:appeal) { create(:appeal) } + let(:orig_decision_issues) do + Array.new(3) do + create( + :decision_issue, + decision_review: appeal, + disposition: "denied" + ) + 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(:vacate_type) { nil } @@ -109,6 +118,14 @@ expect(org_task.status).to eq Constants.TASK_STATUSES.completed end + + it "saves all decision issue IDs for full grant" do + subject.process + motion = PostDecisionMotion.first + + 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)) + end end context "when vacate type is vacate and de novo" do From 84e4cac34f69b2208a286d1e7daf218938abf307 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Tue, 24 Dec 2019 10:12:44 -0500 Subject: [PATCH 09/30] linting --- spec/workflows/post_decision_motion_updater_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index a9bdd04951c..1c49cf906aa 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -122,7 +122,7 @@ it "saves all decision issue IDs for full grant" do subject.process motion = PostDecisionMotion.first - + 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)) end From 18451dc84942b2520ac510205c7904dc5204b7b0 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Thu, 2 Jan 2020 11:44:00 -0800 Subject: [PATCH 10/30] updated schema to indicate addtl usage of vacated_decision_issue_ids field --- ...decision_issue_ids_description_on_post_decision_motion.rb | 5 +++++ db/schema.rb | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20200102193042_update_vacated_decision_issue_ids_description_on_post_decision_motion.rb diff --git a/db/migrate/20200102193042_update_vacated_decision_issue_ids_description_on_post_decision_motion.rb b/db/migrate/20200102193042_update_vacated_decision_issue_ids_description_on_post_decision_motion.rb new file mode 100644 index 00000000000..c370cba362a --- /dev/null +++ b/db/migrate/20200102193042_update_vacated_decision_issue_ids_description_on_post_decision_motion.rb @@ -0,0 +1,5 @@ +class UpdateVacatedDecisionIssueIdsDescriptionOnPostDecisionMotion < ActiveRecord::Migration[5.1] + def change + change_column_comment :post_decision_motions, :vacated_decision_issue_ids, "When a motion to vacate is partially granted, this includes an array of the appeal's decision issue IDs that were chosen for vacatur in this post-decision motion. For full grant, this includes all prior decision issue IDs." + end +end diff --git a/db/schema.rb b/db/schema.rb index 733f193261b..97e455816c4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20191219155741) do +ActiveRecord::Schema.define(version: 20200102193042) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -918,7 +918,7 @@ t.bigint "task_id" t.datetime "updated_at", null: false t.string "vacate_type", comment: "Granted motion to vacate can be Straight Vacate, Vacate and Readjudication, or Vacate and De Novo." - t.integer "vacated_decision_issue_ids", comment: "When a motion to vacate is partially granted, this includes an array of the appeal's decision issue IDs that were chosen for vacatur in this post-decision motion", array: true + t.integer "vacated_decision_issue_ids", comment: "When a motion to vacate is partially granted, this includes an array of the appeal's decision issue IDs that were chosen for vacatur in this post-decision motion. For full grant, this includes all prior decision issue IDs.", array: true t.index ["task_id"], name: "index_post_decision_motions_on_task_id" t.index ["updated_at"], name: "index_post_decision_motions_on_updated_at" end From 84140b95d75fddc2f805435245ce8a27b2a82ebc Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Thu, 2 Jan 2020 11:44:22 -0800 Subject: [PATCH 11/30] better logic for populating vacated_decision_issue_ids field in PostDecisionMotionUpdater --- 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 8df289a145e..e0db2882266 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -28,7 +28,7 @@ def create_motion vacate_type: params[:vacate_type] ) - if params.key?(:vacated_decision_issue_ids) + if disposition == "partial" motion.vacated_decision_issue_ids = params[:vacated_decision_issue_ids] elsif disposition == "granted" # For full grant, auto populate all decision issue IDs From 4707bfc692b8d4c55fb602e2501118dc40a0574a Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Thu, 2 Jan 2020 13:58:06 -0800 Subject: [PATCH 12/30] fixed wrong naming in disposition check in PostDecisionMotionUpdater --- 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 e0db2882266..719d619a023 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -28,7 +28,7 @@ def create_motion vacate_type: params[:vacate_type] ) - if disposition == "partial" + if disposition == "partially_granted" motion.vacated_decision_issue_ids = params[:vacated_decision_issue_ids] elsif disposition == "granted" # For full grant, auto populate all decision issue IDs From 504fc8155ec6a86331e7a37605430f7781f0ee35 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Fri, 3 Jan 2020 16:15:14 -0800 Subject: [PATCH 13/30] removed superfluous commented line --- app/models/post_decision_motion.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/post_decision_motion.rb b/app/models/post_decision_motion.rb index 34500cd1442..5b8334f49a6 100644 --- a/app/models/post_decision_motion.rb +++ b/app/models/post_decision_motion.rb @@ -3,8 +3,6 @@ class PostDecisionMotion < ApplicationRecord belongs_to :task, optional: false - # has_many :decision_issues as: :vacated_issues - validates :disposition, presence: true validate :vacate_type_is_present_if_granted validate :vacated_issues_present_if_partial From c0b14b82ee35b83cb80ab688c21d15f8e24d253b Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Mon, 6 Jan 2020 09:26:17 -0800 Subject: [PATCH 14/30] moved logic for creating request issue from decision issue to DecisionIssue --- app/models/decision_issue.rb | 15 +++++++++++++++ app/models/post_decision_motion.rb | 15 +-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/models/decision_issue.rb b/app/models/decision_issue.rb index f4d5c528a4e..8ba1f667ba1 100644 --- a/app/models/decision_issue.rb +++ b/app/models/decision_issue.rb @@ -155,6 +155,21 @@ def associated_request_issue request_issues.first end + def new_request_issue_from! + RequestIssue.create!( + decision_review: decision_review, + decision_review_type: decision_review_type, + contested_decision_issue_id: id, + contested_rating_issue_reference_id: rating_issue_reference_id, + contested_rating_issue_profile_date: rating_profile_date, + contested_issue_description: description, + nonrating_issue_category: nonrating_issue_category, + benefit_type: benefit_type, + decision_date: caseflow_decision_date, + veteran_participant_id: decision_review.veteran.participant_id + ) + end + private def fetch_diagnostic_code_status_description(diagnostic_code) diff --git a/app/models/post_decision_motion.rb b/app/models/post_decision_motion.rb index 5b8334f49a6..d88047b38a8 100644 --- a/app/models/post_decision_motion.rb +++ b/app/models/post_decision_motion.rb @@ -28,20 +28,7 @@ def vacated_issues end def create_request_issues_for_vacature - vacated_issues.map do |prev_decision_issue| - RequestIssue.create!( - decision_review: prev_decision_issue.decision_review, - decision_review_type: prev_decision_issue.decision_review_type, - contested_decision_issue_id: prev_decision_issue.id, - contested_rating_issue_reference_id: prev_decision_issue.rating_issue_reference_id, - contested_rating_issue_profile_date: prev_decision_issue.rating_profile_date, - contested_issue_description: prev_decision_issue.description, - nonrating_issue_category: prev_decision_issue.nonrating_issue_category, - benefit_type: prev_decision_issue.benefit_type, - decision_date: prev_decision_issue.caseflow_decision_date, - veteran_participant_id: task.appeal.veteran.participant_id - ) - end + vacated_issues.map(&:new_request_issue_from!) end private From ae016df29cd0034406b25adef003ab6a7da45a73 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Tue, 7 Jan 2020 19:21:29 -0800 Subject: [PATCH 15/30] began adding new_decision_issue_from! method to RequestIssue --- app/models/request_issue.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/models/request_issue.rb b/app/models/request_issue.rb index 09425ab03f3..135f9dd178b 100644 --- a/app/models/request_issue.rb +++ b/app/models/request_issue.rb @@ -161,6 +161,19 @@ def from_intake_data(data, decision_review: nil) new(attrs).tap(&:validate_eligibility!) end + def new_decision_issue_from! + DecisionIssue.create!( + decision_review: decision_review, + decision_review_type: decision_review_type, + disposition: 'vacated', + description: "The decision: #{description} has been vacated.", + caseflow_decision_date: Date.today, + benefit_type: benefit_type, + decision_date: caseflow_decision_date, + veteran_participant_id: decision_review.veteran.participant_id + ) + end + private # rubocop:disable Metrics/MethodLength From dc869f3be9920922f7d11fb5a2ec3e25a5fcaa94 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Wed, 15 Jan 2020 16:32:40 -0800 Subject: [PATCH 16/30] updated method name in RequestIssue to "create_vacated_decision_issue!" --- app/models/request_issue.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/request_issue.rb b/app/models/request_issue.rb index ff1c7d61aff..cf61ef772d0 100644 --- a/app/models/request_issue.rb +++ b/app/models/request_issue.rb @@ -162,7 +162,7 @@ def from_intake_data(data, decision_review: nil) new(attrs).tap(&:validate_eligibility!) end - def new_decision_issue_from! + def create_vacated_decision_issue! DecisionIssue.create!( decision_review: decision_review, decision_review_type: decision_review_type, From 9c4536f353b51ab1979cecb0cae6af5f6564d681 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Wed, 15 Jan 2020 17:30:50 -0800 Subject: [PATCH 17/30] added code & tests for generating vacated decision issues from PostDecisionMotion; moved `create_vacated_decision_issue` in RequestIssue to make method accessible; --- app/models/post_decision_motion.rb | 8 ++++++-- app/models/request_issue.rb | 25 ++++++++++++------------ spec/models/post_decision_motion_spec.rb | 24 ++++++++++++++++++----- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/app/models/post_decision_motion.rb b/app/models/post_decision_motion.rb index 6cec41976e4..7d86ff779cf 100644 --- a/app/models/post_decision_motion.rb +++ b/app/models/post_decision_motion.rb @@ -27,8 +27,12 @@ def vacated_issues DecisionIssue.find(vacated_decision_issue_ids) end - def create_request_issues_for_vacature - vacated_issues.map(&:create_contesting_request_issue!) + def request_issues_for_vacature + @request_issues_for_vacature ||= vacated_issues.map(&:create_contesting_request_issue!) + end + + def vacated_decision_issues + @vacated_decision_issues ||= request_issues_for_vacature.map(&:create_vacated_decision_issue!) end private diff --git a/app/models/request_issue.rb b/app/models/request_issue.rb index cf61ef772d0..3475887402d 100644 --- a/app/models/request_issue.rb +++ b/app/models/request_issue.rb @@ -162,19 +162,6 @@ def from_intake_data(data, decision_review: nil) new(attrs).tap(&:validate_eligibility!) end - def create_vacated_decision_issue! - DecisionIssue.create!( - decision_review: decision_review, - decision_review_type: decision_review_type, - disposition: 'vacated', - description: "The decision: #{description} has been vacated.", - caseflow_decision_date: Date.today, - benefit_type: benefit_type, - decision_date: caseflow_decision_date, - veteran_participant_id: decision_review.veteran.participant_id - ) - end - private # rubocop:disable Metrics/MethodLength @@ -484,6 +471,18 @@ def create_decision_issue_from_params(decision_issue_param) ) end + def create_vacated_decision_issue! + DecisionIssue.create!( + decision_review: decision_review, + decision_review_type: decision_review_type, + disposition: 'vacated', + description: "The decision: #{description} has been vacated.", + caseflow_decision_date: Date.today, + benefit_type: benefit_type, + participant_id: decision_review.veteran.participant_id + ) + end + def requires_record_request_task? eligible? && !is_unidentified && !benefit_type_requires_payee_code? end diff --git a/spec/models/post_decision_motion_spec.rb b/spec/models/post_decision_motion_spec.rb index 1bb658a20bf..c2968023e7d 100644 --- a/spec/models/post_decision_motion_spec.rb +++ b/spec/models/post_decision_motion_spec.rb @@ -10,11 +10,13 @@ let(:motions_atty) { create(:user, full_name: "Motions attorney") } let(:appeal) { create(:appeal) } let(:orig_decision_issues) do - Array.new(3) do + Array.new(3) do |index| create( :decision_issue, decision_review: appeal, - disposition: "denied" + disposition: "denied", + description: "issue #{index}", + participant_id: appeal.veteran.participant_id ) end end @@ -46,10 +48,22 @@ let(:vacate_type) { "vacate_and_readjudication" } it "creates a request issue for every selected decision issue" do - expect(appeal.request_issues.length).to eq 0 - post_decision_motion.create_request_issues_for_vacature + expect(appeal.request_issues.size).to eq 0 + post_decision_motion.request_issues_for_vacature appeal.reload - expect(appeal.request_issues.length).to eq 3 + expect(appeal.request_issues.size).to eq 3 + end + end + + context "handles creation of vacated decision issues" do + let(:disposition) { "granted" } + let(:vacate_type) { "vacate_and_readjudication" } + + it "creates a vacated decision issue for every selected decision issue" do + expect(post_decision_motion.vacated_issues.size).to eq 3 + post_decision_motion.vacated_decision_issues + appeal.reload + expect(appeal.decision_issues.size).to eq 6 end end end From 425cdf9412de489e4bba80fdf3b37fdc24505ba0 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Wed, 15 Jan 2020 17:43:40 -0800 Subject: [PATCH 18/30] adjustments per codeclimate --- app/models/request_issue.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/request_issue.rb b/app/models/request_issue.rb index 3475887402d..90461e1f3c4 100644 --- a/app/models/request_issue.rb +++ b/app/models/request_issue.rb @@ -475,9 +475,9 @@ def create_vacated_decision_issue! DecisionIssue.create!( decision_review: decision_review, decision_review_type: decision_review_type, - disposition: 'vacated', + disposition: "vacated", description: "The decision: #{description} has been vacated.", - caseflow_decision_date: Date.today, + caseflow_decision_date: Time.zone.today, benefit_type: benefit_type, participant_id: decision_review.veteran.participant_id ) From f6842467872c8a3e6f566cce70700a6aa996f96f Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Tue, 21 Jan 2020 09:32:16 -0800 Subject: [PATCH 19/30] updated various items in DecisionIssue, RequestIssue, & PostDecisionMotion: renamed methods, and separated methods for creation of issues from those that return said issues; renamed tests; --- app/models/decision_issue.rb | 2 +- app/models/post_decision_motion.rb | 16 ++++++++++++---- app/models/request_issue.rb | 2 +- spec/models/post_decision_motion_spec.rb | 13 ++++++++----- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/models/decision_issue.rb b/app/models/decision_issue.rb index fb7c8a2fa2a..45b845651c8 100644 --- a/app/models/decision_issue.rb +++ b/app/models/decision_issue.rb @@ -160,7 +160,7 @@ def associated_request_issue end def create_contesting_request_issue! - RequestIssue.create!( + RequestIssue.find_or_create_by!( decision_review: decision_review, decision_review_type: decision_review_type, contested_decision_issue_id: id, diff --git a/app/models/post_decision_motion.rb b/app/models/post_decision_motion.rb index 7d86ff779cf..3b7f86383fc 100644 --- a/app/models/post_decision_motion.rb +++ b/app/models/post_decision_motion.rb @@ -21,18 +21,26 @@ class PostDecisionMotion < ApplicationRecord vacate_and_de_novo: "vacate_and_de_novo" } - def vacated_issues + def decision_issues_for_vacatur return [] unless vacated_decision_issue_ids DecisionIssue.find(vacated_decision_issue_ids) end - def request_issues_for_vacature - @request_issues_for_vacature ||= vacated_issues.map(&:create_contesting_request_issue!) + def request_issues_for_vacatur + @request_issues_for_vacatur ||= RequestIssue.where(contested_decision_issue_id: vacated_decision_issue_ids) + end + + def create_request_issues_for_vacatur + decision_issues_for_vacatur.map(&:create_contesting_request_issue!) end def vacated_decision_issues - @vacated_decision_issues ||= request_issues_for_vacature.map(&:create_vacated_decision_issue!) + @vacated_decision_issues ||= request_issues_for_vacatur.map { |ri| ri.decision_issues.first } + end + + def create_vacated_decision_issues + request_issues_for_vacatur.map(&:create_vacated_decision_issue!) end private diff --git a/app/models/request_issue.rb b/app/models/request_issue.rb index e64cee7581d..ba96d5956f4 100644 --- a/app/models/request_issue.rb +++ b/app/models/request_issue.rb @@ -473,7 +473,7 @@ def create_decision_issue_from_params(decision_issue_param) end def create_vacated_decision_issue! - DecisionIssue.create!( + decision_issues.find_or_create_by!( decision_review: decision_review, decision_review_type: decision_review_type, disposition: "vacated", diff --git a/spec/models/post_decision_motion_spec.rb b/spec/models/post_decision_motion_spec.rb index c2968023e7d..b57382c52b0 100644 --- a/spec/models/post_decision_motion_spec.rb +++ b/spec/models/post_decision_motion_spec.rb @@ -43,25 +43,28 @@ lit_support_team.add_user(motions_atty) end - context "handles creation of request issues" do + context "#create_request_issues_for_vacatur" do let(:disposition) { "granted" } let(:vacate_type) { "vacate_and_readjudication" } + subject { post_decision_motion.create_request_issues_for_vacatur } it "creates a request issue for every selected decision issue" do expect(appeal.request_issues.size).to eq 0 - post_decision_motion.request_issues_for_vacature + subject appeal.reload expect(appeal.request_issues.size).to eq 3 end end - context "handles creation of vacated decision issues" do + context "#create_vacated_decision_issues" do let(:disposition) { "granted" } let(:vacate_type) { "vacate_and_readjudication" } + subject { post_decision_motion.create_vacated_decision_issues } it "creates a vacated decision issue for every selected decision issue" do - expect(post_decision_motion.vacated_issues.size).to eq 3 - post_decision_motion.vacated_decision_issues + expect(post_decision_motion.decision_issues_for_vacatur.size).to eq 3 + post_decision_motion.create_request_issues_for_vacatur + subject appeal.reload expect(appeal.decision_issues.size).to eq 6 end From ea02577ea3b9339f823a6f1d37409e97a591dd5f Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Tue, 21 Jan 2020 11:41:22 -0800 Subject: [PATCH 20/30] fixed error in MTV 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 37cb280d6fa..ea43c983f56 100644 --- a/spec/feature/queue/motion_to_vacate_spec.rb +++ b/spec/feature/queue/motion_to_vacate_spec.rb @@ -307,7 +307,7 @@ motion = PostDecisionMotion.find_by(task: judge_address_motion_to_vacate_task) expect(motion).to_not be_nil expect(motion.disposition).to eq("partially_granted") - expect(motion.vacated_issues.length).to eq(issues_to_select.length) + expect(motion.decision_issues_for_vacatur.length).to eq(issues_to_select.length) # Verify new task creation instructions = format_judge_instructions( From 7d01a8bd44f38f430c4c7a801d55dfce995bf49f Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Tue, 21 Jan 2020 15:39:16 -0800 Subject: [PATCH 21/30] began adding PostDecisionMotionController.create_issues endpoint & tests --- .../post_decision_motions_controller.rb | 25 ++++++++++++++++++ config/routes.rb | 1 + .../post_decision_motions_controller_spec.rb | 26 +++++++++++++++++++ spec/factories/post_decision_motions.rb | 21 +++++++++++++-- 4 files changed, 71 insertions(+), 2 deletions(-) diff --git a/app/controllers/post_decision_motions_controller.rb b/app/controllers/post_decision_motions_controller.rb index 94588836a6b..39bac986328 100644 --- a/app/controllers/post_decision_motions_controller.rb +++ b/app/controllers/post_decision_motions_controller.rb @@ -25,6 +25,18 @@ def return_to_lit_support render json: { tasks: ::WorkQueue::TaskSerializer.new(appeal_tasks, is_collection: true) } end + def create_issues + binding.pry + new_request_issues = post_decision_motion.create_request_issues_for_vacatur + + new_decision_issues = post_decision_motion.create_vacated_decision_issues + + render json: { + request_issues: Intake::RequestIssueSerializer.new(new_request_issues, is_collection: true), + decision_issues: Intake::DecisionIssueSerializer.new(new_decision_issues, is_collection: true) + } + end + private def verify_task_access @@ -40,4 +52,17 @@ def task def motion_params params.permit(:disposition, :task_id, :vacate_type, :instructions, :assigned_to_id, vacated_decision_issue_ids: []) end + + def create_issues_params + params.permit(:id) + end + + def motion_id + binding.pry + create_issues_params[:id] + end + + def post_decision_motion + PostDecisionMotion.find(motion_id) + end end diff --git a/config/routes.rb b/config/routes.rb index 657e2c4cc77..bf9aee33438 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -302,6 +302,7 @@ end post "post_decision_motions/return", to: "post_decision_motions#return_to_lit_support" + post "post_decision_motions/:id/create_issues", to: "post_decision_motions#create_issues" post "post_decision_motions", to: "post_decision_motions#create" # :nocov: diff --git a/spec/controllers/post_decision_motions_controller_spec.rb b/spec/controllers/post_decision_motions_controller_spec.rb index 7be557f03ad..b57a4b74e3a 100644 --- a/spec/controllers/post_decision_motions_controller_spec.rb +++ b/spec/controllers/post_decision_motions_controller_spec.rb @@ -5,6 +5,8 @@ let(:judge) { create(:user) } let(:judge_team) { JudgeTeam.create_for_judge(judge) } + let(:post_decision_motion) { create(:post_decision_motion) } + before do User.authenticate!(roles: ["System Admin"]) User.stub = judge @@ -73,6 +75,30 @@ end end + describe "#create_issues" do + context "with a valid PostDecisionMotion id" do + it "returns a 200 response" do + allow(controller).to receive(:verify_authentication).and_return(true) + + task = create_task_without_unnecessary_models + assigned_to = user + judge_team.add_user(user) + + appeal = post_decision_motion.reload.task.appeal + + + post :create_issues, params: { "id": post_decision_motion.id } + + appeal.reload + + binding.pry + + expect(response).to be_success + expect(appeal.decision_issues.size).to eq(6) + end + end + end + def create_task_without_unnecessary_models appeal = create(:appeal) assigned_by = create(:user) diff --git a/spec/factories/post_decision_motions.rb b/spec/factories/post_decision_motions.rb index eafbe495b16..77a87a5c936 100644 --- a/spec/factories/post_decision_motions.rb +++ b/spec/factories/post_decision_motions.rb @@ -2,7 +2,24 @@ FactoryBot.define do factory :post_decision_motion do - disposition { "MyString" } - task { nil } + task { create(:judge_address_motion_to_vacate_task) } + disposition { "granted" } + vacate_type { "straight_vacate" } + + before(:create) do |post_decision_motion| + appeal = post_decision_motion.task.appeal + return unless appeal.reload.decision_issues.size == 0 + + 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 From 1e2baaa32c84c8c861a0818f8afc85c18a972762 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Wed, 22 Jan 2020 12:17:38 -0800 Subject: [PATCH 22/30] added "create_issues" endpoint on PostDecisionMotionsController: this creates request issues & decision issues based off the specified PostDecisionMotion --- .../post_decision_motions_controller.rb | 5 +-- .../post_decision_motions_controller_spec.rb | 37 +++++++++++++++---- spec/support/capybara.rb | 3 ++ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/app/controllers/post_decision_motions_controller.rb b/app/controllers/post_decision_motions_controller.rb index 39bac986328..238c6524b29 100644 --- a/app/controllers/post_decision_motions_controller.rb +++ b/app/controllers/post_decision_motions_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class PostDecisionMotionsController < ApplicationController - before_action :verify_task_access + before_action :verify_task_access, only: [:create, :return_to_lit_support] def create motion_updater = PostDecisionMotionUpdater.new(task, motion_params) @@ -26,8 +26,8 @@ def return_to_lit_support end def create_issues - binding.pry new_request_issues = post_decision_motion.create_request_issues_for_vacatur + binding.pry new_decision_issues = post_decision_motion.create_vacated_decision_issues @@ -58,7 +58,6 @@ def create_issues_params end def motion_id - binding.pry create_issues_params[:id] end diff --git a/spec/controllers/post_decision_motions_controller_spec.rb b/spec/controllers/post_decision_motions_controller_spec.rb index b57a4b74e3a..5b8fdb363c9 100644 --- a/spec/controllers/post_decision_motions_controller_spec.rb +++ b/spec/controllers/post_decision_motions_controller_spec.rb @@ -77,26 +77,47 @@ describe "#create_issues" do context "with a valid PostDecisionMotion id" do - it "returns a 200 response" do + it "returns a 200 response and creates issues" do allow(controller).to receive(:verify_authentication).and_return(true) - task = create_task_without_unnecessary_models - assigned_to = user + create_task_without_unnecessary_models judge_team.add_user(user) - appeal = post_decision_motion.reload.task.appeal + appeal = post_decision_motion.task.appeal.reload - - post :create_issues, params: { "id": post_decision_motion.id } + expect(appeal.decision_issues.size).to eq(3) - appeal.reload + post :create_issues, params: { id: post_decision_motion.id } - binding.pry + appeal.reload expect(response).to be_success + expect(appeal.request_issues.size).to eq(3) expect(appeal.decision_issues.size).to eq(6) end end + + context "with an invalid PostDecisionMotion id" do + it "returns a 404 response and doesn't create issues" do + allow(controller).to receive(:verify_authentication).and_return(true) + + create_task_without_unnecessary_models + judge_team.add_user(user) + + appeal = post_decision_motion.task.appeal.reload + + expect(appeal.decision_issues.size).to eq(3) + expect(appeal.request_issues.size).to eq(3) + + post :create_issues, params: { id: 9999 } + + appeal.reload + + expect(response.status).to eq 404 + expect(appeal.request_issues.size).to eq(3) + expect(appeal.decision_issues.size).to eq(3) + end + end end def create_task_without_unnecessary_models diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index e39ef1d48c5..ade1ae9dfec 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -29,6 +29,9 @@ chrome_options.add_preference(:browser, disk_cache_dir: cache_directory) + chrome_options.add_extension("/Users/jcq/Downloads/React-Developer-Tools_v4.1.0.crx") + chrome_options.add_extension("/Users/jcq/Downloads/Redux-DevTools_v2.17.0.crx") + options = { service: ::Selenium::WebDriver::Service.chrome(args: { port: 51_674 }), browser: :chrome, From 8e788622ed24585b1e9ca77d26a9f6bd8d1fbcdc Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Wed, 22 Jan 2020 13:01:01 -0800 Subject: [PATCH 23/30] linting --- app/controllers/post_decision_motions_controller.rb | 1 - spec/factories/post_decision_motions.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/post_decision_motions_controller.rb b/app/controllers/post_decision_motions_controller.rb index 238c6524b29..e3ab4deb6f0 100644 --- a/app/controllers/post_decision_motions_controller.rb +++ b/app/controllers/post_decision_motions_controller.rb @@ -27,7 +27,6 @@ def return_to_lit_support def create_issues new_request_issues = post_decision_motion.create_request_issues_for_vacatur - binding.pry new_decision_issues = post_decision_motion.create_vacated_decision_issues diff --git a/spec/factories/post_decision_motions.rb b/spec/factories/post_decision_motions.rb index 77a87a5c936..096fd159c86 100644 --- a/spec/factories/post_decision_motions.rb +++ b/spec/factories/post_decision_motions.rb @@ -8,7 +8,7 @@ before(:create) do |post_decision_motion| appeal = post_decision_motion.task.appeal - return unless appeal.reload.decision_issues.size == 0 + return unless appeal.reload.decision_issues.empty? 3.times do |idx| create( From cb160e08515f5853165344d3d983e632fb29f4ff Mon Sep 17 00:00:00 2001 From: jcq <2581274+jcq@users.noreply.github.com> Date: Wed, 22 Jan 2020 13:41:53 -0800 Subject: [PATCH 24/30] removed mistaken commit of modified capybara.rb --- spec/support/capybara.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index ade1ae9dfec..e39ef1d48c5 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -29,9 +29,6 @@ chrome_options.add_preference(:browser, disk_cache_dir: cache_directory) - chrome_options.add_extension("/Users/jcq/Downloads/React-Developer-Tools_v4.1.0.crx") - chrome_options.add_extension("/Users/jcq/Downloads/Redux-DevTools_v2.17.0.crx") - options = { service: ::Selenium::WebDriver::Service.chrome(args: { port: 51_674 }), browser: :chrome, From be25dfff4f0a73c4ec20b4704216610fbf0debab Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Tue, 4 Feb 2020 16:03:14 -0800 Subject: [PATCH 25/30] DecisionIssue.create_contesting_request_issue now adds new request issues to new "vacate" appeal stream --- app/models/decision_issue.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/decision_issue.rb b/app/models/decision_issue.rb index 45b845651c8..d45e26acb6f 100644 --- a/app/models/decision_issue.rb +++ b/app/models/decision_issue.rb @@ -160,8 +160,9 @@ def associated_request_issue end def create_contesting_request_issue! + vacate_appeal_stream = Appeal.find_by(stream_type: "Vacate", stream_docket_number: decision_review.docket_number) RequestIssue.find_or_create_by!( - decision_review: decision_review, + decision_review: vacate_appeal_stream, decision_review_type: decision_review_type, contested_decision_issue_id: id, contested_rating_issue_reference_id: rating_issue_reference_id, From b9ee9a693ebcb1e5ded1ec016252ea464f4688a6 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Fri, 7 Feb 2020 10:10:45 -0800 Subject: [PATCH 26/30] moved calls to create new request & decision issues to PostDecisionMotionUpdater; new issues are created on the vacate stream; --- app/models/decision_issue.rb | 2 +- app/workflows/post_decision_motion_updater.rb | 3 +++ .../post_decision_motion_updater_spec.rb | 22 ++++++++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/models/decision_issue.rb b/app/models/decision_issue.rb index 252638141c0..ef72d557c20 100644 --- a/app/models/decision_issue.rb +++ b/app/models/decision_issue.rb @@ -160,7 +160,7 @@ def associated_request_issue end def create_contesting_request_issue! - vacate_appeal_stream = Appeal.find_by(stream_type: "Vacate", stream_docket_number: decision_review.docket_number) + vacate_appeal_stream = Appeal.find_by(stream_type: "vacate", stream_docket_number: decision_review.docket_number) RequestIssue.find_or_create_by!( decision_review: vacate_appeal_stream, decision_review_type: decision_review_type, diff --git a/app/workflows/post_decision_motion_updater.rb b/app/workflows/post_decision_motion_updater.rb index dd6ef8cd82c..2b49cbe7c40 100644 --- a/app/workflows/post_decision_motion_updater.rb +++ b/app/workflows/post_decision_motion_updater.rb @@ -57,6 +57,7 @@ def create_motion end motion.save + motion end # We create an AbstractMotionToVacateTask as sibling to the JudgeAddressMotionToVacateTask @@ -85,6 +86,8 @@ def handle_grant vacate_stream = appeal.create_stream(:vacate) create_new_stream_tasks(vacate_stream) + post_decision_motion.create_request_issues_for_vacatur + post_decision_motion.create_vacated_decision_issues end def create_abstract_task diff --git a/spec/workflows/post_decision_motion_updater_spec.rb b/spec/workflows/post_decision_motion_updater_spec.rb index ce5f5b886cb..dfbe1e0f30f 100644 --- a/spec/workflows/post_decision_motion_updater_spec.rb +++ b/spec/workflows/post_decision_motion_updater_spec.rb @@ -12,7 +12,7 @@ end let(:motions_atty) { create(:user, full_name: "Motions attorney") } let(:appeal) { create(:appeal) } - let(:orig_decision_issues) do + let!(:orig_decision_issues) do Array.new(3) do create( :decision_issue, @@ -65,6 +65,8 @@ expect(task.reload.status).to eq Constants.TASK_STATUSES.completed verify_vacate_stream end + + it "should create decision issues on new vacate" end context "when vacate type is straight vacate" do @@ -74,6 +76,7 @@ subject.process expect(task.reload.status).to eq Constants.TASK_STATUSES.completed verify_vacate_stream + verify_decision_issues_created end it "saves all decision issue IDs for full grant" do @@ -92,6 +95,8 @@ subject.process expect(task.reload.status).to eq Constants.TASK_STATUSES.completed verify_vacate_stream + verify_vacate_stream + verify_decision_issues_created end end @@ -217,9 +222,11 @@ end end - def verify_vacate_stream - vacate_stream = Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "vacate") + def vacate_stream + Appeal.find_by(stream_docket_number: appeal.docket_number, stream_type: "vacate") + end + def verify_vacate_stream expect(vacate_stream).to_not be_nil expect(vacate_stream.claimant.participant_id).to eq(appeal.claimant.participant_id) @@ -235,4 +242,13 @@ def verify_vacate_stream expect(attorney_task).to_not be_nil end + + def verify_decision_issues_created + motion = PostDecisionMotion.first + request_issues = vacate_stream.request_issues + expect(request_issues.size).to eq(motion.decision_issues_for_vacatur.size) + + decision_issues = vacate_stream.decision_issues + expect(decision_issues.size).to eq(motion.decision_issues_for_vacatur.size) + end end From c376303941623d4cc8bd5d6c07d69b82ec80369f Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Fri, 7 Feb 2020 10:11:02 -0800 Subject: [PATCH 27/30] removed create_issues & related from PostDecisionMotionsController --- .../post_decision_motions_controller.rb | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/app/controllers/post_decision_motions_controller.rb b/app/controllers/post_decision_motions_controller.rb index e3ab4deb6f0..ca65607b02e 100644 --- a/app/controllers/post_decision_motions_controller.rb +++ b/app/controllers/post_decision_motions_controller.rb @@ -25,17 +25,6 @@ def return_to_lit_support render json: { tasks: ::WorkQueue::TaskSerializer.new(appeal_tasks, is_collection: true) } end - def create_issues - new_request_issues = post_decision_motion.create_request_issues_for_vacatur - - new_decision_issues = post_decision_motion.create_vacated_decision_issues - - render json: { - request_issues: Intake::RequestIssueSerializer.new(new_request_issues, is_collection: true), - decision_issues: Intake::DecisionIssueSerializer.new(new_decision_issues, is_collection: true) - } - end - private def verify_task_access @@ -52,14 +41,6 @@ def motion_params params.permit(:disposition, :task_id, :vacate_type, :instructions, :assigned_to_id, vacated_decision_issue_ids: []) end - def create_issues_params - params.permit(:id) - end - - def motion_id - create_issues_params[:id] - end - def post_decision_motion PostDecisionMotion.find(motion_id) end From ba135f4e8012c1c5ad4d878a2149c2013b8ba8be Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Fri, 7 Feb 2020 12:50:59 -0800 Subject: [PATCH 28/30] updated tests in post_decision_motion_spec --- spec/models/post_decision_motion_spec.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/spec/models/post_decision_motion_spec.rb b/spec/models/post_decision_motion_spec.rb index b57382c52b0..ba70364338d 100644 --- a/spec/models/post_decision_motion_spec.rb +++ b/spec/models/post_decision_motion_spec.rb @@ -9,6 +9,7 @@ end let(:motions_atty) { create(:user, full_name: "Motions attorney") } let(:appeal) { create(:appeal) } + let(:vacate_stream) { appeal.create_stream(:vacate) } let(:orig_decision_issues) do Array.new(3) do |index| create( @@ -49,10 +50,10 @@ subject { post_decision_motion.create_request_issues_for_vacatur } it "creates a request issue for every selected decision issue" do - expect(appeal.request_issues.size).to eq 0 + expect(vacate_stream.request_issues.size).to eq 0 subject - appeal.reload - expect(appeal.request_issues.size).to eq 3 + vacate_stream.reload + expect(vacate_stream.request_issues.size).to eq 3 end end @@ -61,12 +62,16 @@ let(:vacate_type) { "vacate_and_readjudication" } subject { post_decision_motion.create_vacated_decision_issues } + before do + vacate_stream.reload + end + it "creates a vacated decision issue for every selected decision issue" do expect(post_decision_motion.decision_issues_for_vacatur.size).to eq 3 post_decision_motion.create_request_issues_for_vacatur subject - appeal.reload - expect(appeal.decision_issues.size).to eq 6 + vacate_stream.reload + expect(vacate_stream.decision_issues.size).to eq 3 end end end From 5d84d902a47547ffc7fe62b7db0100c6504fbe2d Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Fri, 7 Feb 2020 12:52:13 -0800 Subject: [PATCH 29/30] removed tests for PostDecisionMotionsController.create_tasks --- .../post_decision_motions_controller_spec.rb | 45 ------------------- 1 file changed, 45 deletions(-) diff --git a/spec/controllers/post_decision_motions_controller_spec.rb b/spec/controllers/post_decision_motions_controller_spec.rb index b1a5746511f..83eb7b8a278 100644 --- a/spec/controllers/post_decision_motions_controller_spec.rb +++ b/spec/controllers/post_decision_motions_controller_spec.rb @@ -86,51 +86,6 @@ end end - describe "#create_issues" do - context "with a valid PostDecisionMotion id" do - it "returns a 200 response and creates issues" do - allow(controller).to receive(:verify_authentication).and_return(true) - - create_task_without_unnecessary_models - judge_team.add_user(user) - - appeal = post_decision_motion.task.appeal.reload - - expect(appeal.decision_issues.size).to eq(3) - - post :create_issues, params: { id: post_decision_motion.id } - - appeal.reload - - expect(response).to be_success - expect(appeal.request_issues.size).to eq(3) - expect(appeal.decision_issues.size).to eq(6) - end - end - - context "with an invalid PostDecisionMotion id" do - it "returns a 404 response and doesn't create issues" do - allow(controller).to receive(:verify_authentication).and_return(true) - - create_task_without_unnecessary_models - judge_team.add_user(user) - - appeal = post_decision_motion.task.appeal.reload - - expect(appeal.decision_issues.size).to eq(3) - expect(appeal.request_issues.size).to eq(3) - - post :create_issues, params: { id: 9999 } - - appeal.reload - - expect(response.status).to eq 404 - expect(appeal.request_issues.size).to eq(3) - expect(appeal.decision_issues.size).to eq(3) - end - end - end - def create_task_without_unnecessary_models appeal = create(:appeal) assigned_by = create(:user) From 583d3de3dff1a2f4e3a07d1c9fe13960ef6d9c07 Mon Sep 17 00:00:00 2001 From: JC Quirin Date: Fri, 7 Feb 2020 13:11:43 -0800 Subject: [PATCH 30/30] removed unsed route for create_issues off of PostDecisionMotionsController --- config/routes.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index db5b4bc3734..68d2973d371 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -301,7 +301,6 @@ end post "post_decision_motions/return", to: "post_decision_motions#return_to_lit_support" - post "post_decision_motions/:id/create_issues", to: "post_decision_motions#create_issues" post "post_decision_motions", to: "post_decision_motions#create" # :nocov: