Skip to content

Commit

Permalink
API-45023-recache-mpi-after-icn (#20798)
Browse files Browse the repository at this point in the history
* API-45023-recache-mpi-after-icn

* WIP
	* re caches MPI data once we have the ICN
	* adds method to enable re fetching the cache on MPI data
 Changes to be committed:
	modified:   modules/claims_api/app/controllers/claims_api/v1/application_controller.rb
	modified:   modules/claims_api/app/models/claims_api/veteran.rb

* Rubocop fix

* API-45023-recache-mpi-after-icn

* Adds call to recache MPI data when building from headers after we have the ICN
* Adds test that new method is called
* Clean up
	Cleans up a comment line from another file that was not necessary
	modified:   modules/claims_api/app/controllers/claims_api/v1/application_controller.rb
	new file:   modules/claims_api/spec/controllers/v1/application_controller_spec.rb
	modified:   modules/claims_api/spec/controllers/v1/disability_compensation_controller_spec.rb

* API-45023-recache-mpi-after-icn

* Adds flipper for `add_person_proxy` update
* Adjusts related tests
	modified:   config/features.yml
	modified:   modules/claims_api/app/controllers/claims_api/v1/application_controller.rb
	modified:   modules/claims_api/spec/controllers/v1/application_controller_spec.rb
	modified:   modules/claims_api/spec/requests/v1/forms/2122_spec.rb
	modified:   modules/claims_api/spec/requests/v1/forms/526_spec.rb
  • Loading branch information
rockwellwindsor-va authored Feb 18, 2025
1 parent 65cf4b0 commit b0f0159
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ features:
actor_type: user
description: When enabled, sends 526 forms to BD via the refactored logic
enable_in_development: true
lighthouse_claims_api_add_person_proxy:
actor_type: user
description: When enabled, will allow for add_person_proxy call in both versions
enable_in_development: true
confirmation_page_new:
actor_type: user
description: Enables the 2024 version of the confirmation page view in simple forms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ def veteran_from_headers(with_gender: false) # rubocop:disable Metrics/MethodLen
vet.edipi = vet.edipi_mpi
vet.participant_id = vet.participant_id_mpi
vet.icn = vet&.mpi_icn
if Flipper.enabled?(:lighthouse_claims_api_add_person_proxy)
vet.recache_mpi_data # This will cache using the ICN as the KEY in Redis now if it is present
end
vet
end

Expand Down
4 changes: 4 additions & 0 deletions modules/claims_api/app/models/claims_api/veteran.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def mpi
@mpi ||= MPIData.for_user(self)
end

def recache_mpi_data
@mpi = MPIData.for_user(self)
end

def mpi_record?(user_key: uuid)
mpi&.mvi_response(user_key:)&.ok?
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# frozen_string_literal: true

require 'rails_helper'
# require 'mock_redis'

RSpec.describe ClaimsApi::V1::ApplicationController, type: :controller do
let(:controller) { described_class.new }
let(:with_gender) { false }

before do
allow(Flipper).to receive(:enabled?).with(:lighthouse_claims_api_add_person_proxy).and_return(true)

allow(controller).to receive(:header).with('X-VA-SSN').and_return('123456789')
allow(controller).to receive(:header).with('X-VA-First-Name').and_return('Jake')
allow(controller).to receive(:header).with('X-VA-Last-Name').and_return('Doe')
allow(controller).to receive(:header).with('X-VA-Birth-Date').and_return('1967-05-06')

controller.instance_variable_set(:@is_valid_ccg_flow, true)
@veteran_instance = double('Veteran')
allow(ClaimsApi::Veteran).to receive(:new).and_return(@veteran_instance)

allow(@veteran_instance).to receive(:mpi_record?).and_return(true)
allow(@veteran_instance).to receive(:edipi=)
allow(@veteran_instance).to receive(:edipi_mpi)
allow(@veteran_instance).to receive(:edipi)
allow(@veteran_instance).to receive(:participant_id_mpi)
allow(@veteran_instance).to receive(:participant_id=)
allow(@veteran_instance).to receive(:participant_id)
allow(@veteran_instance).to receive(:mpi_icn)
allow(@veteran_instance).to receive(:icn=)
allow(@veteran_instance).to receive(:icn)
end

describe '#veteran_from_headers' do
it 'calls the recache method when building from headers' do
allow(@veteran_instance).to receive(:recache_mpi_data)
controller.send(:veteran_from_headers, with_gender: with_gender)

expect(@veteran_instance).to have_received(:recache_mpi_data)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

# spec/controllers/disability_compensation_controller_spec.rb

require 'rails_helper'

RSpec.describe ClaimsApi::V1::Forms::DisabilityCompensationController, type: :controller do
Expand Down
1 change: 1 addition & 0 deletions modules/claims_api/spec/requests/v1/forms/2122_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
allow(Flipper).to receive(:enabled?).with(:claims_load_testing).and_return false
allow(Flipper).to receive(:enabled?).with(:claims_api_use_person_web_service).and_return true
allow(Flipper).to receive(:enabled?).with(:lighthouse_claims_api_poa_dependent_claimants).and_return false
allow(Flipper).to receive(:enabled?).with(:lighthouse_claims_api_add_person_proxy).and_return true
end

describe '#2122' do
Expand Down
4 changes: 4 additions & 0 deletions modules/claims_api/spec/requests/v1/forms/526_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2363,6 +2363,7 @@ def obj.class
context "when feature flag is #{flipped}" do
before do
allow(Flipper).to receive(:enabled?).with(:claims_api_526_validations_v1_local_bgs).and_return(flipped)
allow(Flipper).to receive(:enabled?).with(:lighthouse_claims_api_add_person_proxy).and_return(flipped)
if flipped
expect_any_instance_of(ClaimsApi::StandardDataService)
.to receive(:get_contention_classification_type_code_list).and_return(classification_type_codes)
Expand Down Expand Up @@ -2408,6 +2409,7 @@ def obj.class
[true, false].each do |flipped|
context "when feature flag is #{flipped}" do
before do
allow(Flipper).to receive(:enabled?).with(:lighthouse_claims_api_add_person_proxy).and_return(flipped)
allow(Flipper).to receive(:enabled?).with(:claims_api_526_validations_v1_local_bgs).and_return(flipped)
if flipped
expect_any_instance_of(ClaimsApi::StandardDataService)
Expand Down Expand Up @@ -2566,6 +2568,7 @@ def obj.class
[true, false].each do |flipped|
context "when feature flag is #{flipped}" do
before do
allow(Flipper).to receive(:enabled?).with(:lighthouse_claims_api_add_person_proxy).and_return(flipped)
allow(Flipper).to receive(:enabled?).with(:claims_api_526_validations_v1_local_bgs).and_return(flipped)
if flipped
allow_any_instance_of(ClaimsApi::StandardDataService)
Expand Down Expand Up @@ -3296,6 +3299,7 @@ def obj.class
}

allow(Flipper).to receive(:enabled?).with(:claims_load_testing).and_return false
allow(Flipper).to receive(:enabled?).with(:lighthouse_claims_api_add_person_proxy).and_return(true)
allow_any_instance_of(ClaimsApi::SupportingDocumentUploader).to receive(:store!)
allow_any_instance_of(ClaimsApi::BD).to(
receive(:upload).and_raise(Common::Exceptions::BackendServiceException.new(
Expand Down

0 comments on commit b0f0159

Please sign in to comment.