From 3e45a15d4fdfed35f90216d262f89d3f47917eb0 Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Mon, 5 Jun 2023 16:23:12 -0400 Subject: [PATCH 01/22] Adding initial remediation script as per APPEALS-23500 --- lib/helpers/poa_access.rb | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lib/helpers/poa_access.rb diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb new file mode 100644 index 00000000000..0df5e60d660 --- /dev/null +++ b/lib/helpers/poa_access.rb @@ -0,0 +1,51 @@ +=begin +Legacy Appeals - no POA access when spouse not located in people table +=end + +# frozen_string_literal: true + +module WarRoom + module PoaAccess + def run(file_number:) + RequestStore[:current_user] = User.system_user + + appeal = Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id(file_number) + + # locate poa and verify it returns no record + # returns an nil record which we will need to delete later + poa = appeal.power_of_attorney + + unless poa.bgs_record == :not_found + puts("bgs record was found. Aborting...") + fail Interrupt + end + + # 2. Setup - Locate Participant ID. + + # 3. Execute - + + # Clean up + # clear memoization on legacy appeals + appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) + + poa = appeal.bgs_power_of_attorney + + if poa.blank? + # noop + elsif poa.bgs_record == :not_found + poa.destroy! + end + + # Create person record + person = Person.find_or_create_by_participant_id(poa_participant_id) + + # Create bgs POA record + # NOTE: The POA is updated in a before_save callback. It will pull in all the attrs for the created POA + BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(poa_participant_id) + + # 4. Confirm fix + appeal = Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id("some_file_num") + appeal.bgs_power_of_attorney.present? + end + end +end From dc621b279c538a6cec97a3c1a1203b2ad816d5bb Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Wed, 7 Jun 2023 12:11:18 -0400 Subject: [PATCH 02/22] Adding spec and updating script accordingly. --- lib/helpers/poa_access.rb | 62 ++++++++++++++--------------- spec/lib/helpers/poa_access_spec.rb | 18 +++++++++ 2 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 spec/lib/helpers/poa_access_spec.rb diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index 0df5e60d660..c27925ea55b 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -1,51 +1,49 @@ -=begin -Legacy Appeals - no POA access when spouse not located in people table -=end - # frozen_string_literal: true module WarRoom - module PoaAccess - def run(file_number:) + class PoaAccess + # Legacy Appeals - no POA access when spouse not in people table + def initialize(appeals_id, poa_participant_id) + @appeals_id = appeals_id + @poa_participant_id = poa_participant_id RequestStore[:current_user] = User.system_user + end - appeal = Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id(file_number) - - # locate poa and verify it returns no record - # returns an nil record which we will need to delete later - poa = appeal.power_of_attorney - + def run + # only allow records that are not_found to be remidiated unless poa.bgs_record == :not_found - puts("bgs record was found. Aborting...") + puts("bgs record exists. Aborting...") fail Interrupt end - # 2. Setup - Locate Participant ID. - - # 3. Execute - - - # Clean up - # clear memoization on legacy appeals - appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) - - poa = appeal.bgs_power_of_attorney - - if poa.blank? - # noop - elsif poa.bgs_record == :not_found - poa.destroy! - end + # due diligence to clean up records that may have been created when looking for an existing record + purge_poa! # Create person record - person = Person.find_or_create_by_participant_id(poa_participant_id) + Person.find_or_create_by_participant_id(@poa_participant_id) # Create bgs POA record # NOTE: The POA is updated in a before_save callback. It will pull in all the attrs for the created POA - BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(poa_participant_id) + BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(@poa_participant_id) - # 4. Confirm fix - appeal = Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id("some_file_num") + # Confirm fix appeal.bgs_power_of_attorney.present? end + + def appeal + Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id(@appeals_id) + end + + def poa + # clear memoization on legacy appeals + appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) + appeal.bgs_power_of_attorney + end + + private + + def purge_poa! + poa.destroy! + end end end diff --git a/spec/lib/helpers/poa_access_spec.rb b/spec/lib/helpers/poa_access_spec.rb new file mode 100644 index 00000000000..304692517dd --- /dev/null +++ b/spec/lib/helpers/poa_access_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require "helpers/poa_access" + +describe "WarRoom::PoaAccess" do + let(:legacy_appeal) { create(:legacy_appeal) } + let(:bgs_poa) { create(:bgs_power_of_attorney) } + let(:error_type) { Interrupt } + + context "when run against a legacy appeal" do + subject { WarRoom::PoaAccess.new(legacy_appeal.id, bgs_poa.participant_id).run } + it "aborts when poa is present" do + expect(subject).to raise_error do |error| + expect(error).to be_a(error_type) + end + end + end +end From 09cb830cc2e75653a4e8ef3b896d347c7a059f27 Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Mon, 5 Jun 2023 16:23:12 -0400 Subject: [PATCH 03/22] Adding initial remediation script as per APPEALS-23500 --- lib/helpers/poa_access.rb | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lib/helpers/poa_access.rb diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb new file mode 100644 index 00000000000..0df5e60d660 --- /dev/null +++ b/lib/helpers/poa_access.rb @@ -0,0 +1,51 @@ +=begin +Legacy Appeals - no POA access when spouse not located in people table +=end + +# frozen_string_literal: true + +module WarRoom + module PoaAccess + def run(file_number:) + RequestStore[:current_user] = User.system_user + + appeal = Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id(file_number) + + # locate poa and verify it returns no record + # returns an nil record which we will need to delete later + poa = appeal.power_of_attorney + + unless poa.bgs_record == :not_found + puts("bgs record was found. Aborting...") + fail Interrupt + end + + # 2. Setup - Locate Participant ID. + + # 3. Execute - + + # Clean up + # clear memoization on legacy appeals + appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) + + poa = appeal.bgs_power_of_attorney + + if poa.blank? + # noop + elsif poa.bgs_record == :not_found + poa.destroy! + end + + # Create person record + person = Person.find_or_create_by_participant_id(poa_participant_id) + + # Create bgs POA record + # NOTE: The POA is updated in a before_save callback. It will pull in all the attrs for the created POA + BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(poa_participant_id) + + # 4. Confirm fix + appeal = Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id("some_file_num") + appeal.bgs_power_of_attorney.present? + end + end +end From 56d16432a5267b49852710d2b4ed40b1ce6cde82 Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Wed, 7 Jun 2023 12:11:18 -0400 Subject: [PATCH 04/22] Adding spec and updating script accordingly. --- lib/helpers/poa_access.rb | 62 ++++++++++++++--------------- spec/lib/helpers/poa_access_spec.rb | 18 +++++++++ 2 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 spec/lib/helpers/poa_access_spec.rb diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index 0df5e60d660..c27925ea55b 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -1,51 +1,49 @@ -=begin -Legacy Appeals - no POA access when spouse not located in people table -=end - # frozen_string_literal: true module WarRoom - module PoaAccess - def run(file_number:) + class PoaAccess + # Legacy Appeals - no POA access when spouse not in people table + def initialize(appeals_id, poa_participant_id) + @appeals_id = appeals_id + @poa_participant_id = poa_participant_id RequestStore[:current_user] = User.system_user + end - appeal = Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id(file_number) - - # locate poa and verify it returns no record - # returns an nil record which we will need to delete later - poa = appeal.power_of_attorney - + def run + # only allow records that are not_found to be remidiated unless poa.bgs_record == :not_found - puts("bgs record was found. Aborting...") + puts("bgs record exists. Aborting...") fail Interrupt end - # 2. Setup - Locate Participant ID. - - # 3. Execute - - - # Clean up - # clear memoization on legacy appeals - appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) - - poa = appeal.bgs_power_of_attorney - - if poa.blank? - # noop - elsif poa.bgs_record == :not_found - poa.destroy! - end + # due diligence to clean up records that may have been created when looking for an existing record + purge_poa! # Create person record - person = Person.find_or_create_by_participant_id(poa_participant_id) + Person.find_or_create_by_participant_id(@poa_participant_id) # Create bgs POA record # NOTE: The POA is updated in a before_save callback. It will pull in all the attrs for the created POA - BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(poa_participant_id) + BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(@poa_participant_id) - # 4. Confirm fix - appeal = Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id("some_file_num") + # Confirm fix appeal.bgs_power_of_attorney.present? end + + def appeal + Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id(@appeals_id) + end + + def poa + # clear memoization on legacy appeals + appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) + appeal.bgs_power_of_attorney + end + + private + + def purge_poa! + poa.destroy! + end end end diff --git a/spec/lib/helpers/poa_access_spec.rb b/spec/lib/helpers/poa_access_spec.rb new file mode 100644 index 00000000000..304692517dd --- /dev/null +++ b/spec/lib/helpers/poa_access_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require "helpers/poa_access" + +describe "WarRoom::PoaAccess" do + let(:legacy_appeal) { create(:legacy_appeal) } + let(:bgs_poa) { create(:bgs_power_of_attorney) } + let(:error_type) { Interrupt } + + context "when run against a legacy appeal" do + subject { WarRoom::PoaAccess.new(legacy_appeal.id, bgs_poa.participant_id).run } + it "aborts when poa is present" do + expect(subject).to raise_error do |error| + expect(error).to be_a(error_type) + end + end + end +end From 7c7e982b170ae4d0e002e91b7fc6dad451821d0d Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Mon, 26 Jun 2023 16:53:58 -0400 Subject: [PATCH 05/22] Updating spec for POA Access --- lib/helpers/poa_access.rb | 8 ++++---- spec/lib/helpers/poa_access_spec.rb | 22 +++++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index c27925ea55b..a8958c5f839 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -3,8 +3,8 @@ module WarRoom class PoaAccess # Legacy Appeals - no POA access when spouse not in people table - def initialize(appeals_id, poa_participant_id) - @appeals_id = appeals_id + def initialize(vacols_id, poa_participant_id) + @vacols_id = vacols_id @poa_participant_id = poa_participant_id RequestStore[:current_user] = User.system_user end @@ -26,12 +26,12 @@ def run # NOTE: The POA is updated in a before_save callback. It will pull in all the attrs for the created POA BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(@poa_participant_id) - # Confirm fix + # Confirm fix by returning the POA for passed in appeal appeal.bgs_power_of_attorney.present? end def appeal - Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id(@appeals_id) + Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id(@vacols_id) end def poa diff --git a/spec/lib/helpers/poa_access_spec.rb b/spec/lib/helpers/poa_access_spec.rb index 304692517dd..1c32550771a 100644 --- a/spec/lib/helpers/poa_access_spec.rb +++ b/spec/lib/helpers/poa_access_spec.rb @@ -3,16 +3,24 @@ require "helpers/poa_access" describe "WarRoom::PoaAccess" do - let(:legacy_appeal) { create(:legacy_appeal) } - let(:bgs_poa) { create(:bgs_power_of_attorney) } - let(:error_type) { Interrupt } + let(:appeal) { create(:legacy_appeal, vacols_case: create(:case)) } context "when run against a legacy appeal" do - subject { WarRoom::PoaAccess.new(legacy_appeal.id, bgs_poa.participant_id).run } - it "aborts when poa is present" do - expect(subject).to raise_error do |error| - expect(error).to be_a(error_type) + + subject { WarRoom::PoaAccess.new(appeal.vacols_id, "fake-pid").run } + + it "interrupts when poa is present" do + expect { subject }.to raise_error do |error| + expect(error).to be_a(Interrupt) end end + + subject { WarRoom::PoaAccess.new(appeal.vacols_id, "").run } + + it "creates a person record for spouse" do + allow_any_instance_of(BgsPowerOfAttorney).to receive(:bgs_record).and_return(:not_found) + + expect(subject).to be true + end end end From a6dcf73fdd17c26aa3899b37e05a9392723764e4 Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Tue, 27 Jun 2023 10:03:45 -0400 Subject: [PATCH 06/22] Update poa access script to corrctly represent a claimants pid so we are being specific about what is being found/created --- lib/helpers/poa_access.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index a8958c5f839..75f949344fc 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -3,9 +3,9 @@ module WarRoom class PoaAccess # Legacy Appeals - no POA access when spouse not in people table - def initialize(vacols_id, poa_participant_id) + def initialize(vacols_id, claimant_participant_id) @vacols_id = vacols_id - @poa_participant_id = poa_participant_id + @claimant_participant_id = claimant_participant_id RequestStore[:current_user] = User.system_user end @@ -20,11 +20,11 @@ def run purge_poa! # Create person record - Person.find_or_create_by_participant_id(@poa_participant_id) + Person.find_or_create_by_participant_id(@claimant_participant_id) # Create bgs POA record - # NOTE: The POA is updated in a before_save callback. It will pull in all the attrs for the created POA - BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(@poa_participant_id) + # NOTE: The POA is updated in a before_save callback. It will pull in all data for the created POA + BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(@claimant_participant_id) # Confirm fix by returning the POA for passed in appeal appeal.bgs_power_of_attorney.present? From e3908c1bbd7136b725327e2ef0734abc67a0ce03 Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Tue, 27 Jun 2023 10:04:36 -0400 Subject: [PATCH 07/22] Update spec to correctly build a new poa and use the new poa's pid in the test --- spec/lib/helpers/poa_access_spec.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/spec/lib/helpers/poa_access_spec.rb b/spec/lib/helpers/poa_access_spec.rb index 1c32550771a..40bae9f6888 100644 --- a/spec/lib/helpers/poa_access_spec.rb +++ b/spec/lib/helpers/poa_access_spec.rb @@ -3,21 +3,23 @@ require "helpers/poa_access" describe "WarRoom::PoaAccess" do + before { FeatureToggle.enable!(:poa_auto_refresh) } + after { FeatureToggle.disable!(:poa_auto_refresh) } + let(:appeal) { create(:legacy_appeal, vacols_case: create(:case)) } + let(:poa) { create(:bgs_power_of_attorney, claimant_participant_id: "2", poa_participant_id: "1") } context "when run against a legacy appeal" do - - subject { WarRoom::PoaAccess.new(appeal.vacols_id, "fake-pid").run } - - it "interrupts when poa is present" do + subject { WarRoom::PoaAccess.new(appeal.vacols_id, "not-used").run } + it "interrupts when poa is found" do expect { subject }.to raise_error do |error| expect(error).to be_a(Interrupt) end end - subject { WarRoom::PoaAccess.new(appeal.vacols_id, "").run } - - it "creates a person record for spouse" do + subject { WarRoom::PoaAccess.new(appeal.vacols_id, poa.claimant_participant_id).run } + it "creates a person record for spouse when poa :not_found" do + # To avoid adding to the large amount of dummy data lets just coerce the record to be :not_found allow_any_instance_of(BgsPowerOfAttorney).to receive(:bgs_record).and_return(:not_found) expect(subject).to be true From fe9e47eb3babbb0a428fff75577d68a0d5e1128a Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Tue, 27 Jun 2023 13:07:29 -0400 Subject: [PATCH 08/22] Remove purge_poa! method and roll into run as inline code. --- lib/helpers/poa_access.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index 75f949344fc..1b6a95096de 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -17,7 +17,7 @@ def run end # due diligence to clean up records that may have been created when looking for an existing record - purge_poa! + poa.destroy! # Create person record Person.find_or_create_by_participant_id(@claimant_participant_id) @@ -39,11 +39,5 @@ def poa appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) appeal.bgs_power_of_attorney end - - private - - def purge_poa! - poa.destroy! - end end end From f6ebfb5e8bf7ca4a0366f25da52424349497e848 Mon Sep 17 00:00:00 2001 From: Raymond Hughes <131811099+raymond-hughes@users.noreply.github.com> Date: Thu, 29 Jun 2023 14:54:42 -0400 Subject: [PATCH 09/22] Update lib/helpers/poa_access.rb Co-authored-by: Jeremy Croteau --- lib/helpers/poa_access.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index 1b6a95096de..10a1fcb4168 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -3,6 +3,10 @@ module WarRoom class PoaAccess # Legacy Appeals - no POA access when spouse not in people table + # + # @param vacols_id [String] VACOLS id for Legacy Appeal + # @param claimant_participant_id [String] participant ID of spouse + # @return [true, false] whether the fix was successful def initialize(vacols_id, claimant_participant_id) @vacols_id = vacols_id @claimant_participant_id = claimant_participant_id From 77d3534b97f46d83a5c68d40067b13a720efa125 Mon Sep 17 00:00:00 2001 From: Raymond Hughes <131811099+raymond-hughes@users.noreply.github.com> Date: Thu, 29 Jun 2023 15:07:16 -0400 Subject: [PATCH 10/22] Update lib/helpers/poa_access.rb Co-authored-by: Jeremy Croteau --- lib/helpers/poa_access.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index 10a1fcb4168..c8c35d6dd23 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -34,8 +34,9 @@ def run appeal.bgs_power_of_attorney.present? end - def appeal - Appeal.find_appeal_by_uuid_or_find_or_create_legacy_appeal_by_vacols_id(@vacols_id) + def legacy_appeal + return @legacy_appeal if defined?(@legacy_appeal) + @legacy_appeal = LegacyAppeal.find_by!(vacols_id: @vacols_id) end def poa From 9a6f4b2e2d4925dc01370d99f0d8338acded6fc3 Mon Sep 17 00:00:00 2001 From: Raymond Hughes <131811099+raymond-hughes@users.noreply.github.com> Date: Thu, 29 Jun 2023 15:07:33 -0400 Subject: [PATCH 11/22] Update lib/helpers/poa_access.rb Co-authored-by: Jeremy Croteau --- lib/helpers/poa_access.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index c8c35d6dd23..948f56c83f9 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -39,7 +39,7 @@ def legacy_appeal @legacy_appeal = LegacyAppeal.find_by!(vacols_id: @vacols_id) end - def poa + def find_or_create_bgs_power_of_attorney! # clear memoization on legacy appeals appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) appeal.bgs_power_of_attorney From 503a0a405b32eec4808926a39321479585cff320 Mon Sep 17 00:00:00 2001 From: Raymond Hughes <131811099+raymond-hughes@users.noreply.github.com> Date: Thu, 29 Jun 2023 15:10:42 -0400 Subject: [PATCH 12/22] Update spec/lib/helpers/poa_access_spec.rb Co-authored-by: Jeremy Croteau --- spec/lib/helpers/poa_access_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/lib/helpers/poa_access_spec.rb b/spec/lib/helpers/poa_access_spec.rb index 40bae9f6888..1241b68f2b3 100644 --- a/spec/lib/helpers/poa_access_spec.rb +++ b/spec/lib/helpers/poa_access_spec.rb @@ -3,8 +3,10 @@ require "helpers/poa_access" describe "WarRoom::PoaAccess" do - before { FeatureToggle.enable!(:poa_auto_refresh) } - after { FeatureToggle.disable!(:poa_auto_refresh) } + before do + allow(FeatureToggle).to receive(:enabled?). + with(:poa_auto_refresh, user: RequestStore.store[:current_user]) { true } + end let(:appeal) { create(:legacy_appeal, vacols_case: create(:case)) } let(:poa) { create(:bgs_power_of_attorney, claimant_participant_id: "2", poa_participant_id: "1") } From cc8ed1b6595da059135d6f675b01a5c7fa4afa94 Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Fri, 30 Jun 2023 08:59:49 -0400 Subject: [PATCH 13/22] Update to spec to remove POA interrupt check. --- lib/helpers/poa_access.rb | 22 ++++++---------------- spec/lib/helpers/poa_access_spec.rb | 14 +------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index 948f56c83f9..fc1e1109071 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -1,5 +1,9 @@ # frozen_string_literal: true +# When POA is not accessible some users see an error on frontend. +# Others will see a blank POA and when refreshed the POA will still show empty +# The root cause is no person record and we solve this by grabbing +# a new person record and creating the BGS POA if needed. module WarRoom class PoaAccess # Legacy Appeals - no POA access when spouse not in people table @@ -14,15 +18,6 @@ def initialize(vacols_id, claimant_participant_id) end def run - # only allow records that are not_found to be remidiated - unless poa.bgs_record == :not_found - puts("bgs record exists. Aborting...") - fail Interrupt - end - - # due diligence to clean up records that may have been created when looking for an existing record - poa.destroy! - # Create person record Person.find_or_create_by_participant_id(@claimant_participant_id) @@ -31,18 +26,13 @@ def run BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(@claimant_participant_id) # Confirm fix by returning the POA for passed in appeal - appeal.bgs_power_of_attorney.present? + legacy_appeal.bgs_power_of_attorney.present? end def legacy_appeal return @legacy_appeal if defined?(@legacy_appeal) - @legacy_appeal = LegacyAppeal.find_by!(vacols_id: @vacols_id) - end - def find_or_create_bgs_power_of_attorney! - # clear memoization on legacy appeals - appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) - appeal.bgs_power_of_attorney + @legacy_appeal = LegacyAppeal.find_by!(vacols_id: @vacols_id) end end end diff --git a/spec/lib/helpers/poa_access_spec.rb b/spec/lib/helpers/poa_access_spec.rb index 1241b68f2b3..a025e19a005 100644 --- a/spec/lib/helpers/poa_access_spec.rb +++ b/spec/lib/helpers/poa_access_spec.rb @@ -3,22 +3,10 @@ require "helpers/poa_access" describe "WarRoom::PoaAccess" do - before do - allow(FeatureToggle).to receive(:enabled?). - with(:poa_auto_refresh, user: RequestStore.store[:current_user]) { true } - end - let(:appeal) { create(:legacy_appeal, vacols_case: create(:case)) } - let(:poa) { create(:bgs_power_of_attorney, claimant_participant_id: "2", poa_participant_id: "1") } + let(:poa) { create(:bgs_power_of_attorney) } context "when run against a legacy appeal" do - subject { WarRoom::PoaAccess.new(appeal.vacols_id, "not-used").run } - it "interrupts when poa is found" do - expect { subject }.to raise_error do |error| - expect(error).to be_a(Interrupt) - end - end - subject { WarRoom::PoaAccess.new(appeal.vacols_id, poa.claimant_participant_id).run } it "creates a person record for spouse when poa :not_found" do # To avoid adding to the large amount of dummy data lets just coerce the record to be :not_found From 680e259da1c7fec41ae837663ba824a466fa20ef Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Fri, 30 Jun 2023 09:36:45 -0400 Subject: [PATCH 14/22] Finalize POA test --- spec/lib/helpers/poa_access_spec.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/spec/lib/helpers/poa_access_spec.rb b/spec/lib/helpers/poa_access_spec.rb index a025e19a005..32ffa87c100 100644 --- a/spec/lib/helpers/poa_access_spec.rb +++ b/spec/lib/helpers/poa_access_spec.rb @@ -3,16 +3,21 @@ require "helpers/poa_access" describe "WarRoom::PoaAccess" do - let(:appeal) { create(:legacy_appeal, vacols_case: create(:case)) } - let(:poa) { create(:bgs_power_of_attorney) } + let!(:legacy_appeal) { create(:legacy_appeal, vacols_case: create(:case)) } + let!(:poa) { create(:bgs_power_of_attorney) } context "when run against a legacy appeal" do - subject { WarRoom::PoaAccess.new(appeal.vacols_id, poa.claimant_participant_id).run } - it "creates a person record for spouse when poa :not_found" do + it "creates a person record" do # To avoid adding to the large amount of dummy data lets just coerce the record to be :not_found allow_any_instance_of(BgsPowerOfAttorney).to receive(:bgs_record).and_return(:not_found) - expect(subject).to be true + expect(Person).to receive(:find_or_create_by_participant_id).with(poa.claimant_participant_id) + + expect(BgsPowerOfAttorney).to receive(:find_or_create_by_claimant_participant_id).with(poa.claimant_participant_id) + + remediation_success = WarRoom::PoaAccess.new(legacy_appeal.vacols_id, poa.claimant_participant_id).run + + expect(remediation_success).to be true end end end From 5ce08236306d4d00aa6da99b51f8f514b92d693c Mon Sep 17 00:00:00 2001 From: Jeremy Croteau Date: Fri, 30 Jun 2023 20:36:19 -0400 Subject: [PATCH 15/22] =?UTF-8?q?=F0=9F=9A=A8=20Address=20Reek=20smell:=20?= =?UTF-8?q?WarRoom::PoaAccess=20assumes=20too=20much=20for=20instance=20va?= =?UTF-8?q?riable=20'@legacy=5Fappeal'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/helpers/poa_access.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index fc1e1109071..69eb35c4dfd 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -30,9 +30,7 @@ def run end def legacy_appeal - return @legacy_appeal if defined?(@legacy_appeal) - - @legacy_appeal = LegacyAppeal.find_by!(vacols_id: @vacols_id) + LegacyAppeal.find_by!(vacols_id: @vacols_id) end end end From 936f1ed49c750195b76d1523b53d3037508bb541 Mon Sep 17 00:00:00 2001 From: Jeremy Croteau Date: Fri, 30 Jun 2023 20:37:41 -0400 Subject: [PATCH 16/22] =?UTF-8?q?=F0=9F=9A=A8=20Address=20Reek=20smell:=20?= =?UTF-8?q?Line=20is=20too=20long.=20[121/120]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/lib/helpers/poa_access_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/lib/helpers/poa_access_spec.rb b/spec/lib/helpers/poa_access_spec.rb index 32ffa87c100..6782a9d2377 100644 --- a/spec/lib/helpers/poa_access_spec.rb +++ b/spec/lib/helpers/poa_access_spec.rb @@ -13,7 +13,8 @@ expect(Person).to receive(:find_or_create_by_participant_id).with(poa.claimant_participant_id) - expect(BgsPowerOfAttorney).to receive(:find_or_create_by_claimant_participant_id).with(poa.claimant_participant_id) + expect(BgsPowerOfAttorney).to receive(:find_or_create_by_claimant_participant_id). + with(poa.claimant_participant_id) remediation_success = WarRoom::PoaAccess.new(legacy_appeal.vacols_id, poa.claimant_participant_id).run From 465851fce69c36d946d353c869a1d71010a4f242 Mon Sep 17 00:00:00 2001 From: Jeremy Croteau Date: Fri, 30 Jun 2023 20:47:58 -0400 Subject: [PATCH 17/22] =?UTF-8?q?=F0=9F=9A=A8=20Address=20Reek=20smell:=20?= =?UTF-8?q?Place=20the=20.=20on=20the=20next=20line,=20together=20with=20t?= =?UTF-8?q?he=20method=20name.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/lib/helpers/poa_access_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/helpers/poa_access_spec.rb b/spec/lib/helpers/poa_access_spec.rb index 6782a9d2377..c57f61fd614 100644 --- a/spec/lib/helpers/poa_access_spec.rb +++ b/spec/lib/helpers/poa_access_spec.rb @@ -13,8 +13,8 @@ expect(Person).to receive(:find_or_create_by_participant_id).with(poa.claimant_participant_id) - expect(BgsPowerOfAttorney).to receive(:find_or_create_by_claimant_participant_id). - with(poa.claimant_participant_id) + expect(BgsPowerOfAttorney).to receive(:find_or_create_by_claimant_participant_id) + .with(poa.claimant_participant_id) remediation_success = WarRoom::PoaAccess.new(legacy_appeal.vacols_id, poa.claimant_participant_id).run From 3abd884312f2ead633a036221a03102b7cb70045 Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Mon, 17 Jul 2023 11:26:22 -0400 Subject: [PATCH 18/22] Update script to check for new poa created and avoid checking poa through convulted bgs poa method --- lib/helpers/poa_access.rb | 6 +++--- spec/lib/helpers/poa_access_spec.rb | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index 69eb35c4dfd..2c04f9fecf3 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -23,10 +23,10 @@ def run # Create bgs POA record # NOTE: The POA is updated in a before_save callback. It will pull in all data for the created POA - BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(@claimant_participant_id) + poa = BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(@claimant_participant_id) - # Confirm fix by returning the POA for passed in appeal - legacy_appeal.bgs_power_of_attorney.present? + # Confirm fix by returning the POA by comparing the claimant_participant_id with the new bgs poa claimant_participant_id + poa&.claimant_participant_id == @claimant_participant_id end def legacy_appeal diff --git a/spec/lib/helpers/poa_access_spec.rb b/spec/lib/helpers/poa_access_spec.rb index c57f61fd614..84040c118fe 100644 --- a/spec/lib/helpers/poa_access_spec.rb +++ b/spec/lib/helpers/poa_access_spec.rb @@ -15,6 +15,7 @@ expect(BgsPowerOfAttorney).to receive(:find_or_create_by_claimant_participant_id) .with(poa.claimant_participant_id) + .and_return(poa) remediation_success = WarRoom::PoaAccess.new(legacy_appeal.vacols_id, poa.claimant_participant_id).run From 3f54ae0b034ae85d624538ff9588fcd2a4dea4be Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Mon, 17 Jul 2023 16:19:34 -0400 Subject: [PATCH 19/22] Updating POA job --- lib/helpers/poa_access.rb | 12 ++++++++++-- spec/lib/helpers/poa_access_spec.rb | 7 ++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index 2c04f9fecf3..8beef9bc0b2 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -18,15 +18,23 @@ def initialize(vacols_id, claimant_participant_id) end def run + # clean up any records we don't need + legacy_appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) + poa = legacy_appeal.bgs_power_of_attorney + + if poa.bgs_record == :not_found || poa.claimant_participant_id != @claimant_participant_id + poa.destroy! + end + # Create person record Person.find_or_create_by_participant_id(@claimant_participant_id) # Create bgs POA record # NOTE: The POA is updated in a before_save callback. It will pull in all data for the created POA - poa = BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(@claimant_participant_id) + BgsPowerOfAttorney.find_or_create_by_claimant_participant_id(@claimant_participant_id) # Confirm fix by returning the POA by comparing the claimant_participant_id with the new bgs poa claimant_participant_id - poa&.claimant_participant_id == @claimant_participant_id + legacy_appeal.bgs_power_of_attorney.claimant_participant_id == @claimant_participant_id end def legacy_appeal diff --git a/spec/lib/helpers/poa_access_spec.rb b/spec/lib/helpers/poa_access_spec.rb index 84040c118fe..5b3f24113a1 100644 --- a/spec/lib/helpers/poa_access_spec.rb +++ b/spec/lib/helpers/poa_access_spec.rb @@ -3,14 +3,11 @@ require "helpers/poa_access" describe "WarRoom::PoaAccess" do - let!(:legacy_appeal) { create(:legacy_appeal, vacols_case: create(:case)) } - let!(:poa) { create(:bgs_power_of_attorney) } + let!(:legacy_appeal) { create(:legacy_appeal, vacols_case: create(:case), vbms_id: "000001234") } + let!(:poa) { create(:bgs_power_of_attorney, file_number: "000001234") } context "when run against a legacy appeal" do it "creates a person record" do - # To avoid adding to the large amount of dummy data lets just coerce the record to be :not_found - allow_any_instance_of(BgsPowerOfAttorney).to receive(:bgs_record).and_return(:not_found) - expect(Person).to receive(:find_or_create_by_participant_id).with(poa.claimant_participant_id) expect(BgsPowerOfAttorney).to receive(:find_or_create_by_claimant_participant_id) From 95d9e37c73944ab58fe83eea66ba7456d326e7f5 Mon Sep 17 00:00:00 2001 From: raymond-hughes Date: Fri, 21 Jul 2023 07:57:30 -0400 Subject: [PATCH 20/22] Remove cache clear as its used in bgs poa call and is redundant in this case --- lib/helpers/poa_access.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/helpers/poa_access.rb b/lib/helpers/poa_access.rb index 8beef9bc0b2..dcd295d96d2 100644 --- a/lib/helpers/poa_access.rb +++ b/lib/helpers/poa_access.rb @@ -19,7 +19,6 @@ def initialize(vacols_id, claimant_participant_id) def run # clean up any records we don't need - legacy_appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) poa = legacy_appeal.bgs_power_of_attorney if poa.bgs_record == :not_found || poa.claimant_participant_id != @claimant_participant_id From 18be089004ff31aaf30697343d5df1c5bb05758e Mon Sep 17 00:00:00 2001 From: Raymond Hughes <131811099+raymond-hughes@users.noreply.github.com> Date: Fri, 29 Dec 2023 10:32:54 -0500 Subject: [PATCH 21/22] Update workflow.yml --- .github/workflows/workflow.yml | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 1c7aeb2fb56..61eea933ce5 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -247,33 +247,6 @@ jobs: path: ./log/bullet-${{matrix.ci_node_index}}.log - caseflow_rspec_coverage_report: - runs-on: ubuntu-8-cores-latest - if: ${{ success() }} - needs: caseflow_rspec_job - container: - image: 008577686731.dkr.ecr.us-gov-west-1.amazonaws.com/gaimg-ruby:2.7.3-ga-browsers - credentials: - username: AWS - password: ${{ secrets.ECR_PASSWORD }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - - uses: actions/download-artifact@v3 - - - name: Inflate Coverage tar.gz files - run: | - (cd artifact && for file in coverage-*.tar.gz ; do tar -xvf "$file"; done) - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: '2.7.3' - bundler-cache: true - - name: Run coverage analysis - run: bundle exec rake ci:gha_verify_code_coverage - - caseflow_jest_job: # This job will run the jest, change the value below to false if you wish to turn it off. if: true From 102d6ffeaa45fb04751cb6f9b5da39bc83c66ff7 Mon Sep 17 00:00:00 2001 From: Raymond Hughes <131811099+raymond-hughes@users.noreply.github.com> Date: Fri, 29 Dec 2023 10:33:14 -0500 Subject: [PATCH 22/22] Update workflow.yml --- .github/workflows/workflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 61eea933ce5..224d0b7488e 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -247,6 +247,7 @@ jobs: path: ./log/bullet-${{matrix.ci_node_index}}.log + caseflow_jest_job: # This job will run the jest, change the value below to false if you wish to turn it off. if: true