From 7fc9ec8241d0017fe96daaae002414de50aec42f Mon Sep 17 00:00:00 2001 From: rockwellwindsor-va Date: Tue, 12 Nov 2024 15:43:09 -0600 Subject: [PATCH 1/5] API-41897-remove-updatepoaaccess-for-dependent-claimant * Updates poa updater to skip running poa vbms updater job if we are in the dependent workflow * Adds/updates related tests modified: modules/claims_api/app/sidekiq/claims_api/poa_updater.rb modified: modules/claims_api/spec/sidekiq/poa_updater_spec.rb --- .../app/sidekiq/claims_api/poa_updater.rb | 15 ++++++-- .../spec/sidekiq/poa_updater_spec.rb | 36 ++++++++++++++++++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb b/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb index b1516dd201c..e3a26ebc2fb 100644 --- a/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb +++ b/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb @@ -30,7 +30,9 @@ def perform(power_of_attorney_id, rep = nil) # rubocop:disable Metrics/MethodLen ClaimsApi::VANotifyJob.perform_async(poa_form.id, rep) if vanotify?(poa_form.auth_headers, rep) - ClaimsApi::PoaVBMSUpdater.perform_async(poa_form.id) if enable_vbms_access?(poa_form:) + if enable_vbms_access?(poa_form:) && update_poa_access?(poa_form.auth_headers) + ClaimsApi::PoaVBMSUpdater.perform_async(poa_form.id) + end else poa_form.status = ClaimsApi::PowerOfAttorney::ERRORED poa_form.vbms_error_message = "BGS Error: update_birls_record failed with code #{response[:return_code]}" @@ -42,12 +44,21 @@ def perform(power_of_attorney_id, rep = nil) # rubocop:disable Metrics/MethodLen private + # If we are in the dependent workflow we do not want this job to run + def update_poa_access?(auth_headers) + !depedent_auth_headers_present?(auth_headers) + end + def vanotify?(auth_headers, rep) if Flipper.enabled?(:lighthouse_claims_api_v2_poa_va_notify) - auth_headers.key?(ClaimsApi::V2::Veterans::PowerOfAttorney::BaseController::VA_NOTIFY_KEY) && rep.present? + depedent_auth_headers_present?(auth_headers) && rep.present? else false end end + + def depedent_auth_headers_present?(auth_headers) + auth_headers.key?(ClaimsApi::V2::Veterans::PowerOfAttorney::BaseController::VA_NOTIFY_KEY) + end end end diff --git a/modules/claims_api/spec/sidekiq/poa_updater_spec.rb b/modules/claims_api/spec/sidekiq/poa_updater_spec.rb index 4bbed181432..3910d5d92df 100644 --- a/modules/claims_api/spec/sidekiq/poa_updater_spec.rb +++ b/modules/claims_api/spec/sidekiq/poa_updater_spec.rb @@ -111,6 +111,40 @@ end end + context 'deciding to call PoaVBMSUpdater' do + before do + create_mock_lighthouse_service + end + + let(:poa) { create_poa } + + context 'when the dependent header key is present' do + let(:header_key) { ClaimsApi::V2::Veterans::PowerOfAttorney::BaseController::VA_NOTIFY_KEY } + + it 'does not call PoaVBMSUpdater' do + poa.auth_headers.merge!({ + header_key => 'this_value' + }) + poa.save! + + expect(ClaimsApi::PoaVBMSUpdater).not_to receive(:perform_async) + + subject.new.perform(poa.id, 'Rep Data') + end + end + + context 'when the dependent header key is not present' do + it 'does call PoaVBMSUpdater' do + expect(ClaimsApi::PoaVBMSUpdater).to receive(:perform_async) + + poa.form_data.merge!({ recordConsent: true, consentLimits: [] }) + poa.save! + + subject.new.perform(poa.id, 'Rep Data') + end + end + end + context 'deciding to send a VA Notify email' do before do create_mock_lighthouse_service @@ -119,7 +153,7 @@ let(:poa) { create_poa } let(:header_key) { ClaimsApi::V2::Veterans::PowerOfAttorney::BaseController::VA_NOTIFY_KEY } - context 'when the header key and rep are present' do + context 'when the dependent header key and rep are present' do it 'sends the vanotify job' do poa.auth_headers.merge!({ header_key => 'this_value' From 4da274d544fb3e472ec6ee2af69c23dbdeeb4e27 Mon Sep 17 00:00:00 2001 From: rockwellwindsor-va Date: Tue, 12 Nov 2024 15:58:06 -0600 Subject: [PATCH 2/5] Fixes the check so it checks the correct thing --- modules/claims_api/app/sidekiq/claims_api/poa_updater.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb b/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb index e3a26ebc2fb..cd66f66b1b0 100644 --- a/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb +++ b/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb @@ -51,14 +51,14 @@ def update_poa_access?(auth_headers) def vanotify?(auth_headers, rep) if Flipper.enabled?(:lighthouse_claims_api_v2_poa_va_notify) - depedent_auth_headers_present?(auth_headers) && rep.present? + auth_headers.key?(ClaimsApi::V2::Veterans::PowerOfAttorney::BaseController::VA_NOTIFY_KEY) && rep.present? else false end end def depedent_auth_headers_present?(auth_headers) - auth_headers.key?(ClaimsApi::V2::Veterans::PowerOfAttorney::BaseController::VA_NOTIFY_KEY) + auth_headers.key?('dependent') end end end From 44cc7c88f22332be7e2257315c10fd6b8814a300 Mon Sep 17 00:00:00 2001 From: rockwellwindsor-va Date: Tue, 12 Nov 2024 16:03:07 -0600 Subject: [PATCH 3/5] Fixes incorrect text update --- modules/claims_api/spec/sidekiq/poa_updater_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/claims_api/spec/sidekiq/poa_updater_spec.rb b/modules/claims_api/spec/sidekiq/poa_updater_spec.rb index 3910d5d92df..ff7e6547ebd 100644 --- a/modules/claims_api/spec/sidekiq/poa_updater_spec.rb +++ b/modules/claims_api/spec/sidekiq/poa_updater_spec.rb @@ -153,7 +153,7 @@ let(:poa) { create_poa } let(:header_key) { ClaimsApi::V2::Veterans::PowerOfAttorney::BaseController::VA_NOTIFY_KEY } - context 'when the dependent header key and rep are present' do + context 'when the header key and rep are present' do it 'sends the vanotify job' do poa.auth_headers.merge!({ header_key => 'this_value' From fc0dc40977fb00dde4bca02f3122e87bc746b085 Mon Sep 17 00:00:00 2001 From: rockwellwindsor-va Date: Tue, 12 Nov 2024 16:16:23 -0600 Subject: [PATCH 4/5] Fixes test for dependent scenario --- modules/claims_api/spec/sidekiq/poa_updater_spec.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/claims_api/spec/sidekiq/poa_updater_spec.rb b/modules/claims_api/spec/sidekiq/poa_updater_spec.rb index ff7e6547ebd..cc08687dfdf 100644 --- a/modules/claims_api/spec/sidekiq/poa_updater_spec.rb +++ b/modules/claims_api/spec/sidekiq/poa_updater_spec.rb @@ -119,16 +119,13 @@ let(:poa) { create_poa } context 'when the dependent header key is present' do - let(:header_key) { ClaimsApi::V2::Veterans::PowerOfAttorney::BaseController::VA_NOTIFY_KEY } - it 'does not call PoaVBMSUpdater' do - poa.auth_headers.merge!({ - header_key => 'this_value' - }) - poa.save! - expect(ClaimsApi::PoaVBMSUpdater).not_to receive(:perform_async) + poa.auth_headers.merge!({ dependent: { first_name: 'Test' } }) + poa.form_data.merge!({ recordConsent: true, consentLimits: [] }) + poa.save! + subject.new.perform(poa.id, 'Rep Data') end end From b26e5c33ecde9dfb6a236d679a19343c4bd13b98 Mon Sep 17 00:00:00 2001 From: rockwellwindsor-va Date: Fri, 15 Nov 2024 12:09:48 -0600 Subject: [PATCH 5/5] Removes helper methods --- .../claims_api/app/sidekiq/claims_api/poa_updater.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb b/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb index cd66f66b1b0..85856fdb6a8 100644 --- a/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb +++ b/modules/claims_api/app/sidekiq/claims_api/poa_updater.rb @@ -30,7 +30,7 @@ def perform(power_of_attorney_id, rep = nil) # rubocop:disable Metrics/MethodLen ClaimsApi::VANotifyJob.perform_async(poa_form.id, rep) if vanotify?(poa_form.auth_headers, rep) - if enable_vbms_access?(poa_form:) && update_poa_access?(poa_form.auth_headers) + if enable_vbms_access?(poa_form:) && poa_form.auth_headers['dependent'].blank? ClaimsApi::PoaVBMSUpdater.perform_async(poa_form.id) end else @@ -44,11 +44,6 @@ def perform(power_of_attorney_id, rep = nil) # rubocop:disable Metrics/MethodLen private - # If we are in the dependent workflow we do not want this job to run - def update_poa_access?(auth_headers) - !depedent_auth_headers_present?(auth_headers) - end - def vanotify?(auth_headers, rep) if Flipper.enabled?(:lighthouse_claims_api_v2_poa_va_notify) auth_headers.key?(ClaimsApi::V2::Veterans::PowerOfAttorney::BaseController::VA_NOTIFY_KEY) && rep.present? @@ -56,9 +51,5 @@ def vanotify?(auth_headers, rep) false end end - - def depedent_auth_headers_present?(auth_headers) - auth_headers.key?('dependent') - end end end