Skip to content

Commit

Permalink
Merge branch 'API-43724-remove-local-bgs-refactored-dependencies' of …
Browse files Browse the repository at this point in the history
…github.com:department-of-veterans-affairs/vets-api into API-43724-remove-local-bgs-refactored-dependencies

merges remote
  • Loading branch information
stiehlrod committed Jan 8, 2025
2 parents bc792a5 + 931eb61 commit cf4859a
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/models/va_profile_redis/v2/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Cache
# @param user [User] The current user
#
def self.invalidate(user)
contact_info = VAProfileRedis::V2::ContactInformation.find(user.uuid)
contact_info = VAProfileRedis::V2::ContactInformation.find(user.icn)

contact_info.destroy if contact_info.present?
end
Expand Down
8 changes: 2 additions & 6 deletions app/models/va_profile_redis/v2/contact_information.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def response
end

# This method allows us to populate the local instance of a
# VAProfileRedis::V2::ContactInformation object with the uuid necessary
# VAProfileRedis::V2::ContactInformation object with the icn necessary
# to perform subsequent actions on the key such as deletion.
def populate_from_redis
response_from_redis_or_service
Expand All @@ -167,11 +167,7 @@ def dig_out(key, type, matcher)
end

def response_from_redis_or_service
unless VAProfile::Configuration::SETTINGS.contact_information.cache_enabled
return contact_info_service.get_person
end

do_cached_with(key: @user.uuid) do
do_cached_with(key: @user.icn) do
contact_info_service.get_person
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/va_profile/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def self.base_request_headers
end

def connection
@conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options) do |faraday|
ssl_enabled = Rails.env.production?
@conn ||= Faraday.new(base_path, headers: base_request_headers, request: request_options,
ssl: { verify: ssl_enabled }) do |faraday|
faraday.use :breakers
faraday.use Faraday::Response::RaiseError

Expand Down
1 change: 0 additions & 1 deletion lib/va_profile/v2/contact_information/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ def update_model(model, attr, method_name)
contact_info = VAProfileRedis::V2::ContactInformation.for_user(@user)
model.id = contact_info.public_send(attr)&.id
verb = model.id.present? ? 'put' : 'post'

public_send("#{verb}_#{method_name}", model)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
let!(:user) { sis_user(icn: '9000682') }
let(:json_body_headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } }

before do
allow(Flipper).to receive(:enabled?).with(:va_v3_contact_information_service, instance_of(User)).and_return(false)
allow(Flipper).to receive(:enabled?).with(:remove_pciu, instance_of(User)).and_return(false)
end

describe 'GET providers', :aggregate_failures do
it 'returns 200 with paginated results' do
VCR.use_cassette('mobile/facilities/ppms/community_clinics_near_user', match_requests_on: %i[method uri]) do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/va_profile_redis/v2/cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
VCR.use_cassette('va_profile/v2/contact_information/person', VCR::MATCH_EVERYTHING) do
VAProfileRedis::V2::ContactInformation.for_user(user)
end
expect(VAProfileRedis::V2::ContactInformation.exists?(user.uuid)).to eq(true)
expect(VAProfileRedis::V2::ContactInformation.exists?(user.icn)).to eq(true)

VAProfileRedis::V2::Cache.invalidate(user)

expect(VAProfileRedis::V2::ContactInformation.exists?(user.uuid)).to eq(false)
expect(VAProfileRedis::V2::ContactInformation.exists?(user.icn)).to eq(false)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/models/va_profile_redis/v2/contact_information_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
if VAProfile::Configuration::SETTINGS.contact_information.cache_enabled
expect(contact_info.redis_namespace).to receive(:set).once
end
expect_any_instance_of(VAProfile::V2::ContactInformation::Service).to receive(:get_person).twice
expect_any_instance_of(VAProfile::V2::ContactInformation::Service).to receive(:get_person).once
expect(contact_info.status).to eq 200
expect(contact_info.response.person).to have_deep_attributes(person)
end
Expand All @@ -93,7 +93,7 @@
context 'when there is cached data' do
it 'returns the cached data', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/person', VCR::MATCH_EVERYTHING) do
contact_info.cache(user.uuid, person_response)
contact_info.cache(user.icn, person_response)
expect_any_instance_of(VAProfile::V2::ContactInformation::Service).not_to receive(:get_person)
expect(contact_info.response.person).to have_deep_attributes(person)
end
Expand Down
14 changes: 7 additions & 7 deletions spec/requests/v0/profile/email_addresses_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
end

describe 'POST /v0/profile/email_addresses/create_or_update v2' do
let(:email) { build(:email, :contact_info_v2, vet360_id: user.vet360_id) }
let(:email) { build(:email, :contact_info_v2) }

it 'calls update_email' do
expect_any_instance_of(VAProfile::V2::ContactInformation::Service).to receive(:update_email).and_call_original
Expand All @@ -294,7 +294,7 @@
end

describe 'POST /v0/profile/email_addresses v2' do
let(:email) { build(:email, :contact_info_v2, vet360_id: user.vet360_id) }
let(:email) { build(:email, :contact_info_v2) }

context 'with a 200 response' do
it 'matches the email address schema', :aggregate_failures do
Expand Down Expand Up @@ -395,7 +395,7 @@
end

describe 'PUT /v0/profile/email_addresses v2' do
let(:email) { build(:email, :contact_info_v2, vet360_id: user.vet360_id) }
let(:email) { build(:email, :contact_info_v2) }

context 'with a 200 response' do
it 'matches the email address schema', :aggregate_failures do
Expand Down Expand Up @@ -462,9 +462,9 @@

context 'when effective_end_date is included' do
let(:email) do
build(:email, :contact_info_v2, vet360_id: user.vet360_id,
email_address: '[email protected]',
effective_end_date: '2024-09-09T11:52:03.000-06:00')
build(:email, :contact_info_v2,
email_address: '[email protected]',
effective_end_date: '2024-09-09T11:52:03.000-06:00')
end
let(:id_in_cassette) { 42 }

Expand All @@ -477,7 +477,7 @@

describe 'DELETE /v0/profile/email_addresses v2', :skip_vet360 do
let(:email) do
build(:email, vet360_id: user.vet360_id, email_address: '[email protected]')
build(:email, email_address: '[email protected]')
end

before do
Expand Down

0 comments on commit cf4859a

Please sign in to comment.