Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API-41897-remove-updatepoaaccess-for-dependent-claimant #19428

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion modules/claims_api/app/sidekiq/claims_api/poa_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

@tycol7 tycol7 Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iʼm not sure the extra helper methods add any value. Could we instead just say:

Suggested change
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?

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tycol7 Yep makes sense, b26e5c3

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]}"
Expand All @@ -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?
else
false
end
end

def depedent_auth_headers_present?(auth_headers)
auth_headers.key?('dependent')
end
end
end
31 changes: 31 additions & 0 deletions modules/claims_api/spec/sidekiq/poa_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,37 @@
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
it 'does not call PoaVBMSUpdater' do
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

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
Expand Down
Loading