From aaedff471a25d1b914c5ba915a0baf3f5502983b Mon Sep 17 00:00:00 2001 From: Rachal Cassity Date: Thu, 24 Oct 2024 15:08:17 -0500 Subject: [PATCH 1/9] Updated VAProfile::V2::Address to VAProfile::V3::Address (#19073) * Updated VAProfile::V2::Address to VAProfile::V3::Address * Fixed V2::BaseAddress --- app/controllers/concerns/vet360/writeable.rb | 2 +- .../v2/contact_information.rb | 6 +++--- .../schemas/vet360/contact_information.rb | 2 +- lib/va_profile/models/{v2 => v3}/address.rb | 12 +++++------ .../models/{v2 => v3}/base_address.rb | 2 +- lib/va_profile/models/{v2 => v3}/person.rb | 6 +++--- .../v2/contact_information/person_response.rb | 6 +++--- .../v2/contact_information/service.rb | 2 +- .../transaction_response.rb | 4 ++-- .../mobile/v0/profile/sync_update_service.rb | 2 +- .../spec/services/sync_update_service_spec.rb | 2 +- .../va_profile/{v2 => v3}/addresses.rb | 16 +++++++-------- .../va_profile/{v2 => v3}/persons.rb | 4 ++-- .../models/concerns/cache_aside_spec.rb | 2 +- .../models/{v2 => v3}/address_spec.rb | 20 +++++++++---------- .../v2/contact_information/service_spec.rb | 12 +++++------ .../transaction_response_spec.rb | 4 ++-- .../async_transaction/va_profile/base_spec.rb | 2 +- .../async_transaction/vet360/base_spec.rb | 2 +- .../v2/contact_information_spec.rb | 14 ++++++------- spec/requests/swagger_spec.rb | 8 ++++---- spec/requests/v0/profile/addresses_spec.rb | 12 +++++------ .../support/va_profile/stub_vaprofile_user.rb | 6 +++--- 23 files changed, 74 insertions(+), 74 deletions(-) rename lib/va_profile/models/{v2 => v3}/address.rb (92%) rename lib/va_profile/models/{v2 => v3}/base_address.rb (99%) rename lib/va_profile/models/{v2 => v3}/person.rb (94%) rename spec/factories/va_profile/{v2 => v3}/addresses.rb (80%) rename spec/factories/va_profile/{v2 => v3}/persons.rb (67%) rename spec/lib/va_profile/models/{v2 => v3}/address_spec.rb (93%) diff --git a/app/controllers/concerns/vet360/writeable.rb b/app/controllers/concerns/vet360/writeable.rb index 3d02d70e80a..b7d3bc8638c 100644 --- a/app/controllers/concerns/vet360/writeable.rb +++ b/app/controllers/concerns/vet360/writeable.rb @@ -39,7 +39,7 @@ def invalidate_cache def build_record(type, params) # This needs to be refactored after V2 upgrade is complete model = if type == 'address' && Flipper.enabled?(:va_v3_contact_information_service, @current_user) - 'VAProfile::Models::V2::Address' + 'VAProfile::Models::V3::Address' else "VAProfile::Models::#{type.capitalize}" end diff --git a/app/models/va_profile_redis/v2/contact_information.rb b/app/models/va_profile_redis/v2/contact_information.rb index a3f78fb72e2..ad56dcfa065 100644 --- a/app/models/va_profile_redis/v2/contact_information.rb +++ b/app/models/va_profile_redis/v2/contact_information.rb @@ -2,7 +2,7 @@ require 'va_profile/v2/contact_information/person_response' require 'va_profile/v2/contact_information/service' -require 'va_profile/models/v2/address' +require 'va_profile/models/v3/address' require 'va_profile/models/telephone' require 'common/models/redis_store' require 'common/models/concerns/cache_aside' @@ -53,7 +53,7 @@ def email def residential_address return unless @user.loa3? - dig_out('addresses', 'address_pou', VAProfile::Models::V2::Address::RESIDENCE) + dig_out('addresses', 'address_pou', VAProfile::Models::V3::Address::RESIDENCE) end # Returns the user's mailing address. In VA Profile, a user can only have one @@ -64,7 +64,7 @@ def residential_address def mailing_address return unless @user.loa3? - dig_out('addresses', 'address_pou', VAProfile::Models::V2::Address::CORRESPONDENCE) + dig_out('addresses', 'address_pou', VAProfile::Models::V3::Address::CORRESPONDENCE) end # Returns the user's home phone. In VA Profile, a user can only have one diff --git a/app/swagger/swagger/schemas/vet360/contact_information.rb b/app/swagger/swagger/schemas/vet360/contact_information.rb index 0086dc28901..3aa378dfe12 100644 --- a/app/swagger/swagger/schemas/vet360/contact_information.rb +++ b/app/swagger/swagger/schemas/vet360/contact_information.rb @@ -5,7 +5,7 @@ require 'va_profile/contact_information/service' require 'va_profile/v2/contact_information/service' require 'va_profile/models/address' -require 'va_profile/models/v2/address' +require 'va_profile/models/v3/address' require 'va_profile/models/telephone' require 'va_profile/models/permission' require 'common/models/redis_store' diff --git a/lib/va_profile/models/v2/address.rb b/lib/va_profile/models/v3/address.rb similarity index 92% rename from lib/va_profile/models/v2/address.rb rename to lib/va_profile/models/v3/address.rb index a806a55e51a..87cbe903575 100644 --- a/lib/va_profile/models/v2/address.rb +++ b/lib/va_profile/models/v3/address.rb @@ -4,15 +4,15 @@ module VAProfile module Models - module V2 - class Address < V2::BaseAddress + module V3 + class Address < V3::BaseAddress attribute :bad_address, Boolean validates(:source_date, presence: true) # Converts a decoded JSON response from VAProfile to an instance of the Address model # @param body [Hash] the decoded response body from VAProfile - # @return [VAProfile::Models::V2::Address] the model built from the response body + # @return [VAProfile::Models::V3::Address] the model built from the response body # rubocop:disable Metrics/MethodLength def in_json address_attributes = { @@ -58,10 +58,10 @@ def in_json # Converts a decoded JSON response from VAProfile to an instance of the Address model # @param body [Hash] the decoded response body from VAProfile - # @return [VAProfile::Models::V2::Address] the model built from the response body + # @return [VAProfile::Models::V3::Address] the model built from the response body # rubocop:disable Metrics/MethodLength def self.build_from(body) - VAProfile::Models::V2::Address.new( + VAProfile::Models::V3::Address.new( address_line1: body['address_line1'], address_line2: body['address_line2'], address_line3: body['address_line3'], @@ -96,7 +96,7 @@ def self.build_from(body) # rubocop:enable Metrics/MethodLength def correspondence? - @address_pou == VAProfile::Models::V2::Address::CORRESPONDENCE + @address_pou == VAProfile::Models::V3::Address::CORRESPONDENCE end end end diff --git a/lib/va_profile/models/v2/base_address.rb b/lib/va_profile/models/v3/base_address.rb similarity index 99% rename from lib/va_profile/models/v2/base_address.rb rename to lib/va_profile/models/v3/base_address.rb index 733f56e3c09..62595ee1bd4 100644 --- a/lib/va_profile/models/v2/base_address.rb +++ b/lib/va_profile/models/v3/base_address.rb @@ -7,7 +7,7 @@ module VAProfile module Models - module V2 + module V3 class BaseAddress < Base include VAProfile::Concerns::Defaultable include VAProfile::Concerns::Expirable diff --git a/lib/va_profile/models/v2/person.rb b/lib/va_profile/models/v3/person.rb similarity index 94% rename from lib/va_profile/models/v2/person.rb rename to lib/va_profile/models/v3/person.rb index e403cadd8eb..86d3d065446 100644 --- a/lib/va_profile/models/v2/person.rb +++ b/lib/va_profile/models/v3/person.rb @@ -8,7 +8,7 @@ module VAProfile module Models - module V2 + module V3 class Person < Base attribute :addresses, Array[Address] attribute :created_at, Common::ISO8601Time @@ -24,12 +24,12 @@ class Person < Base # @return [VAProfile::Models::Person] the model built from the response body def self.build_from(body) body ||= {} - addresses = body['addresses']&.map { |a| VAProfile::Models::V2::Address.build_from(a) } + addresses = body['addresses']&.map { |a| VAProfile::Models::V3::Address.build_from(a) } emails = body['emails']&.map { |e| VAProfile::Models::Email.build_from(e) } telephones = body['telephones']&.map { |t| VAProfile::Models::Telephone.build_from(t) } body['permissions']&.map { |t| VAProfile::Models::Permission.build_from(t) } - VAProfile::Models::V2::Person.new( + VAProfile::Models::V3::Person.new( created_at: body['create_date'], source_date: body['source_date'], updated_at: body['update_date'], diff --git a/lib/va_profile/v2/contact_information/person_response.rb b/lib/va_profile/v2/contact_information/person_response.rb index b580e7a6bc3..ae17642faaa 100644 --- a/lib/va_profile/v2/contact_information/person_response.rb +++ b/lib/va_profile/v2/contact_information/person_response.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true require 'va_profile/response' -require 'va_profile/models/v2/person' +require 'va_profile/models/v3/person' module VAProfile module V2 module ContactInformation class PersonResponse < VAProfile::Response - attribute :person, VAProfile::Models::V2::Person + attribute :person, VAProfile::Models::V3::Person attr_reader :response_body @@ -16,7 +16,7 @@ def self.from(raw_response = nil) new( raw_response&.status, - person: VAProfile::Models::V2::Person.build_from(response_body&.dig('bio')) + person: VAProfile::Models::V3::Person.build_from(response_body&.dig('bio')) ) end diff --git a/lib/va_profile/v2/contact_information/service.rb b/lib/va_profile/v2/contact_information/service.rb index 6a6fad0d18f..3d1a1b76788 100644 --- a/lib/va_profile/v2/contact_information/service.rb +++ b/lib/va_profile/v2/contact_information/service.rb @@ -63,7 +63,7 @@ def self.get_person(vet360_id) def update_address(address) address_type = - if address.address_pou == VAProfile::Models::V2::BaseAddress::RESIDENCE + if address.address_pou == VAProfile::Models::V3::BaseAddress::RESIDENCE 'residential' else 'mailing' diff --git a/lib/va_profile/v2/contact_information/transaction_response.rb b/lib/va_profile/v2/contact_information/transaction_response.rb index 2dc52300849..131b5450c63 100644 --- a/lib/va_profile/v2/contact_information/transaction_response.rb +++ b/lib/va_profile/v2/contact_information/transaction_response.rb @@ -56,9 +56,9 @@ def changed_field address_pou = response_body['tx_output'][0]['address_pou'] case address_pou - when VAProfile::Models::V2::BaseAddress::RESIDENCE + when VAProfile::Models::V3::BaseAddress::RESIDENCE :residence_address - when VAProfile::Models::V2::BaseAddress::CORRESPONDENCE + when VAProfile::Models::V3::BaseAddress::CORRESPONDENCE :correspondence_address else :address diff --git a/modules/mobile/app/services/mobile/v0/profile/sync_update_service.rb b/modules/mobile/app/services/mobile/v0/profile/sync_update_service.rb index d6e70a6f74f..3491ec15528 100644 --- a/modules/mobile/app/services/mobile/v0/profile/sync_update_service.rb +++ b/modules/mobile/app/services/mobile/v0/profile/sync_update_service.rb @@ -59,7 +59,7 @@ def save!(http_method, resource_type, params) def build_record(type, params) if type == :address && Flipper.enabled?(:va_v3_contact_information_service, @user) - 'VAProfile::Models::V2::Address' + 'VAProfile::Models::V3::Address' .constantize .new(params) .set_defaults(@user) diff --git a/modules/mobile/spec/services/sync_update_service_spec.rb b/modules/mobile/spec/services/sync_update_service_spec.rb index 3ea3b19ddea..52f6a449305 100644 --- a/modules/mobile/spec/services/sync_update_service_spec.rb +++ b/modules/mobile/spec/services/sync_update_service_spec.rb @@ -99,7 +99,7 @@ # let(:user) { create(:user, :api_auth_v2) } - # let(:params) { build(:va_profile_address_v2, :override, validation_key: nil) } + # let(:params) { build(:va_profile_v3_address, :override, validation_key: nil) } # context 'when it succeeds' do # let(:transaction) do diff --git a/spec/factories/va_profile/v2/addresses.rb b/spec/factories/va_profile/v3/addresses.rb similarity index 80% rename from spec/factories/va_profile/v2/addresses.rb rename to spec/factories/va_profile/v3/addresses.rb index c0ba9f6bd37..f0b7cabb0d0 100644 --- a/spec/factories/va_profile/v2/addresses.rb +++ b/spec/factories/va_profile/v3/addresses.rb @@ -2,10 +2,10 @@ # This will be removed after ContactInformation has been updated FactoryBot.define do - factory :va_profile_address_v2, class: 'VAProfile::Models::V2::Address' do + factory :va_profile_v3_address, class: 'VAProfile::Models::V3::Address' do address_line1 { '140 Rock Creek Rd' } - address_pou { VAProfile::Models::V2::Address::RESIDENCE } - address_type { VAProfile::Models::V2::Address::DOMESTIC } + address_pou { VAProfile::Models::V3::Address::RESIDENCE } + address_type { VAProfile::Models::V3::Address::DOMESTIC } bad_address { true } city { 'Washington' } country_name { 'USA' } @@ -23,23 +23,23 @@ vet360_id { '1781151' } trait :mailing do - address_pou { VAProfile::Models::V2::Address::CORRESPONDENCE } + address_pou { VAProfile::Models::V3::Address::CORRESPONDENCE } address_line1 { '1515 Broadway' } end trait :domestic do - address_type { VAProfile::Models::V2::Address::DOMESTIC } + address_type { VAProfile::Models::V3::Address::DOMESTIC } end trait :international do - address_type { VAProfile::Models::V2::Address::INTERNATIONAL } + address_type { VAProfile::Models::V3::Address::INTERNATIONAL } international_postal_code { '100-0001' } state_code { nil } zip_code { nil } end trait :military_overseas do - address_type { VAProfile::Models::V2::Address::MILITARY } + address_type { VAProfile::Models::V3::Address::MILITARY } end trait :multiple_matches do @@ -50,7 +50,7 @@ end trait :override do - address_pou { VAProfile::Models::V2::Address::CORRESPONDENCE } + address_pou { VAProfile::Models::V3::Address::CORRESPONDENCE } address_line1 { '1494 Martin Luther King Rd' } address_line2 { 'null' } city { 'Fulton' } diff --git a/spec/factories/va_profile/v2/persons.rb b/spec/factories/va_profile/v3/persons.rb similarity index 67% rename from spec/factories/va_profile/v2/persons.rb rename to spec/factories/va_profile/v3/persons.rb index b9986a44b23..33cb1dc6640 100644 --- a/spec/factories/va_profile/v2/persons.rb +++ b/spec/factories/va_profile/v3/persons.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true FactoryBot.define do - factory :person_v2, class: 'VAProfile::Models::V2::Person' do - addresses { [FactoryBot.build(:va_profile_address_v2), FactoryBot.build(:va_profile_address_v2, :mailing)] } + factory :person_v2, class: 'VAProfile::Models::V3::Person' do + addresses { [FactoryBot.build(:va_profile_v3_address), FactoryBot.build(:va_profile_v3_address, :mailing)] } emails { [FactoryBot.build(:email, :contact_info_v2)] } telephones { [FactoryBot.build(:telephone, :contact_info_v2)] } source_date { '2018-04-09T11:52:03-06:00' } diff --git a/spec/lib/common/models/concerns/cache_aside_spec.rb b/spec/lib/common/models/concerns/cache_aside_spec.rb index 83c09cc2108..74bed3f0819 100644 --- a/spec/lib/common/models/concerns/cache_aside_spec.rb +++ b/spec/lib/common/models/concerns/cache_aside_spec.rb @@ -49,7 +49,7 @@ before do Flipper.enable(:va_v3_contact_information_service) - allow(VAProfile::Models::V2::Person).to receive(:build_from).and_return(person) + allow(VAProfile::Models::V3::Person).to receive(:build_from).and_return(person) end describe '#do_cached_with', :initiate_vaprofile, :skip_vet360 do diff --git a/spec/lib/va_profile/models/v2/address_spec.rb b/spec/lib/va_profile/models/v3/address_spec.rb similarity index 93% rename from spec/lib/va_profile/models/v2/address_spec.rb rename to spec/lib/va_profile/models/v3/address_spec.rb index 197852ab1d2..934fb929c57 100644 --- a/spec/lib/va_profile/models/v2/address_spec.rb +++ b/spec/lib/va_profile/models/v3/address_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true require 'rails_helper' -require 'va_profile/models/v2/address' +require 'va_profile/models/v3/address' -describe VAProfile::Models::V2::Address do - let(:address) { build(:va_profile_address_v2) } +describe VAProfile::Models::V3::Address do + let(:address) { build(:va_profile_v3_address) } describe 'geolocation' do it 'returns gelocation information' do @@ -107,7 +107,7 @@ end context 'when address_type is domestic' do - let(:address) { build(:va_profile_address_v2, :domestic) } + let(:address) { build(:va_profile_v3_address, :domestic) } it 'city must only have US-ASCII characters' do address.city = '12-34 2nd & 31st Street!' @@ -142,7 +142,7 @@ end context 'when address_type is international' do - let(:address) { build(:va_profile_address_v2, :international) } + let(:address) { build(:va_profile_v3_address, :international) } it 'province must only have US-ASCII characters' do address.province = '12-34 2nd & 31st Street!' @@ -204,7 +204,7 @@ end context 'when address_type is military' do - let(:address) { build(:va_profile_address_v2, :military_overseas) } + let(:address) { build(:va_profile_v3_address, :military_overseas) } it 'state_code is required' do expect(address.valid?).to eq(true) @@ -233,12 +233,12 @@ context 'when address pou is correspondence' do it 'correspondence? is true' do - address.address_pou = VAProfile::Models::V2::Address::CORRESPONDENCE + address.address_pou = VAProfile::Models::V3::Address::CORRESPONDENCE expect(address.correspondence?).to eq(true) end it 'bad address is false' do - address.address_pou = VAProfile::Models::V2::Address::CORRESPONDENCE + address.address_pou = VAProfile::Models::V3::Address::CORRESPONDENCE json = JSON.parse(address.in_json) expect(json['bio']['badAddress']).to eq(false) end @@ -246,12 +246,12 @@ context 'when address pou is residence' do it 'correspondence? is false' do - address.address_pou = VAProfile::Models::V2::Address::RESIDENCE + address.address_pou = VAProfile::Models::V3::Address::RESIDENCE expect(address.correspondence?).to eq(false) end it 'bad address is nil' do - address.address_pou = VAProfile::Models::V2::Address::RESIDENCE + address.address_pou = VAProfile::Models::V3::Address::RESIDENCE json = JSON.parse(address.in_json) expect(json['bio']['badAddress']).to eq(nil) end diff --git a/spec/lib/va_profile/v2/contact_information/service_spec.rb b/spec/lib/va_profile/v2/contact_information/service_spec.rb index ffaf5845a96..7d2631332e3 100644 --- a/spec/lib/va_profile/v2/contact_information/service_spec.rb +++ b/spec/lib/va_profile/v2/contact_information/service_spec.rb @@ -24,7 +24,7 @@ VCR.use_cassette('va_profile/v2/contact_information/person', VCR::MATCH_EVERYTHING) do response = subject.get_person expect(response).to be_ok - expect(response.person).to be_a(VAProfile::Models::V2::Person) + expect(response.person).to be_a(VAProfile::Models::V3::Person) end end @@ -50,7 +50,7 @@ VCR.use_cassette('va_profile/v2/contact_information/person_without_data', VCR::MATCH_EVERYTHING) do response = subject.get_person expect(response).to be_ok - expect(response.person).to be_a(VAProfile::Models::V2::Person) + expect(response.person).to be_a(VAProfile::Models::V3::Person) end end end @@ -154,7 +154,7 @@ describe '#post_address' do let(:address) do - build(:va_profile_address_v2, vet360_id: user.vet360_id, source_system_user: user.icn) + build(:va_profile_v3_address, vet360_id: user.vet360_id, source_system_user: user.icn) end context 'when successful' do @@ -191,7 +191,7 @@ describe '#put_address' do let(:address) do - build(:va_profile_address_v2, :override, vet360_id: user.vet360_id, source_system_user: user.icn) + build(:va_profile_v3_address, :override, vet360_id: user.vet360_id, source_system_user: user.icn) end context 'when successful' do @@ -214,7 +214,7 @@ context 'with a validation key' do let(:address) do - build(:va_profile_address_v2, :override, country_name: nil) + build(:va_profile_v3_address, :override, country_name: nil) end it 'overrides the address error', run_at: '2020-02-14T00:19:15.000Z' do @@ -318,7 +318,7 @@ [ { model_name: 'address', - factory: 'va_profile_address_v2', + factory: 'va_profile_v3_address', trait: 'contact_info_v2', attr: 'residential_address', id: 577_127 diff --git a/spec/lib/va_profile/v2/contact_information/transaction_response_spec.rb b/spec/lib/va_profile/v2/contact_information/transaction_response_spec.rb index 9887ed13274..e12e09fbcfc 100644 --- a/spec/lib/va_profile/v2/contact_information/transaction_response_spec.rb +++ b/spec/lib/va_profile/v2/contact_information/transaction_response_spec.rb @@ -33,7 +33,7 @@ context 'with a residence address change' do before do - body['tx_output'][0]['address_pou'] = VAProfile::Models::V2::BaseAddress::RESIDENCE + body['tx_output'][0]['address_pou'] = VAProfile::Models::V3::BaseAddress::RESIDENCE end it 'has the correct changed field' do @@ -43,7 +43,7 @@ context 'with a correspondence address change' do before do - body['tx_output'][0]['address_pou'] = VAProfile::Models::V2::BaseAddress::CORRESPONDENCE + body['tx_output'][0]['address_pou'] = VAProfile::Models::V3::BaseAddress::CORRESPONDENCE end it 'has the correct changed field' do diff --git a/spec/models/async_transaction/va_profile/base_spec.rb b/spec/models/async_transaction/va_profile/base_spec.rb index 8a4b9659417..af37768d53c 100644 --- a/spec/models/async_transaction/va_profile/base_spec.rb +++ b/spec/models/async_transaction/va_profile/base_spec.rb @@ -366,7 +366,7 @@ def last_transactions_by_class let(:user) { build(:user, :loa3) } let!(:user_verification) { create(:user_verification, idme_uuid: user.idme_uuid) } - let(:address) { build(:va_profile_address_v2, vet360_id: user.vet360_id, source_system_user: user.icn) } + let(:address) { build(:va_profile_v3_address, vet360_id: user.vet360_id, source_system_user: user.icn) } it 'returns an instance with the user uuid', :aggregate_failures do VCR.use_cassette('va_profile/v2/contact_information/post_address_success', VCR::MATCH_EVERYTHING) do diff --git a/spec/models/async_transaction/vet360/base_spec.rb b/spec/models/async_transaction/vet360/base_spec.rb index a9cf13e5c16..7c575c7c82a 100644 --- a/spec/models/async_transaction/vet360/base_spec.rb +++ b/spec/models/async_transaction/vet360/base_spec.rb @@ -249,7 +249,7 @@ let(:user) { build(:user, :loa3) } let!(:user_verification) { create(:user_verification, idme_uuid: user.idme_uuid) } - let(:address) { build(:va_profile_address_v2, vet360_id: user.vet360_id, source_system_user: user.icn) } + let(:address) { build(:va_profile_v3_address, vet360_id: user.vet360_id, source_system_user: user.icn) } it 'returns an instance with the user uuid', :aggregate_failures do VCR.use_cassette('va_profile/v2/contact_information/post_address_success', VCR::MATCH_EVERYTHING) do diff --git a/spec/models/va_profile_redis/v2/contact_information_spec.rb b/spec/models/va_profile_redis/v2/contact_information_spec.rb index e3a21c09a1f..29a3960b177 100644 --- a/spec/models/va_profile_redis/v2/contact_information_spec.rb +++ b/spec/models/va_profile_redis/v2/contact_information_spec.rb @@ -23,7 +23,7 @@ before do Flipper.enable(:va_v3_contact_information_service) - allow(VAProfile::Models::V2::Person).to receive(:build_from).and_return(person) + allow(VAProfile::Models::V3::Person).to receive(:build_from).and_return(person) end [404, 400].each do |status| @@ -104,7 +104,7 @@ describe 'contact information attributes' do context 'with a successful response' do before do - allow(VAProfile::Models::V2::Person).to receive(:build_from).and_return(person) + allow(VAProfile::Models::V3::Person).to receive(:build_from).and_return(person) allow_any_instance_of( VAProfile::V2::ContactInformation::Service ).to receive(:get_person).and_return(person_response) @@ -121,20 +121,20 @@ describe '#residential_address' do it 'returns the users residential address object', :aggregate_failures do - residence = address_for VAProfile::Models::V2::Address::RESIDENCE + residence = address_for VAProfile::Models::V3::Address::RESIDENCE VCR.use_cassette('va_profile/v2/contact_information/person', VCR::MATCH_EVERYTHING) do expect(contact_info.residential_address).to eq residence - expect(contact_info.residential_address.class).to eq VAProfile::Models::V2::Address + expect(contact_info.residential_address.class).to eq VAProfile::Models::V3::Address end end end describe '#mailing_address' do it 'returns the users mailing address object', :aggregate_failures do - correspondence = address_for VAProfile::Models::V2::Address::CORRESPONDENCE + correspondence = address_for VAProfile::Models::V3::Address::CORRESPONDENCE VCR.use_cassette('va_profile/v2/contact_information/person', VCR::MATCH_EVERYTHING) do expect(contact_info.mailing_address).to eq correspondence - expect(contact_info.mailing_address.class).to eq VAProfile::Models::V2::Address + expect(contact_info.mailing_address.class).to eq VAProfile::Models::V3::Address end end end @@ -270,7 +270,7 @@ end before do - allow(VAProfile::Models::V2::Person).to receive(:build_from).and_return(nil) + allow(VAProfile::Models::V3::Person).to receive(:build_from).and_return(nil) allow_any_instance_of( VAProfile::V2::ContactInformation::Service ).to receive(:get_person).and_return(empty_response) diff --git a/spec/requests/swagger_spec.rb b/spec/requests/swagger_spec.rb index eb8bbe46e63..18b737a7210 100644 --- a/spec/requests/swagger_spec.rb +++ b/spec/requests/swagger_spec.rb @@ -2944,7 +2944,7 @@ it 'supports va_profile create or update address api' do expect(subject).to validate(:post, '/v0/profile/addresses/create_or_update', 401) VCR.use_cassette('va_profile/v2/contact_information/put_address_success') do - address = build(:va_profile_address_v2, id: 15_035) + address = build(:va_profile_v3_address, id: 15_035) expect(subject).to validate( :post, @@ -2959,7 +2959,7 @@ expect(subject).to validate(:post, '/v0/profile/addresses', 401) VCR.use_cassette('va_profile/v2/contact_information/post_address_success') do - address = build(:va_profile_address_v2) + address = build(:va_profile_v3_address) expect(subject).to validate( :post, @@ -2974,7 +2974,7 @@ expect(subject).to validate(:put, '/v0/profile/addresses', 401) VCR.use_cassette('va_profile/v2/contact_information/put_address_success') do - address = build(:va_profile_address_v2, id: 15_035) + address = build(:va_profile_v3_address, id: 15_035) expect(subject).to validate( :put, @@ -2989,7 +2989,7 @@ expect(subject).to validate(:delete, '/v0/profile/addresses', 401) VCR.use_cassette('va_profile/v2/contact_information/delete_address_success') do - address = build(:va_profile_address_v2, id: 15_035) + address = build(:va_profile_v3_address, id: 15_035) expect(subject).to validate( :delete, diff --git a/spec/requests/v0/profile/addresses_spec.rb b/spec/requests/v0/profile/addresses_spec.rb index fdec12216da..9cbfb6bb676 100644 --- a/spec/requests/v0/profile/addresses_spec.rb +++ b/spec/requests/v0/profile/addresses_spec.rb @@ -336,7 +336,7 @@ # after do # Flipper.disable(:va_v3_contact_information_service) # end - # let(:address) { build(:va_profile_address_v2, vet360_id: user.vet360_id) } + # let(:address) { build(:va_profile_v3_address, vet360_id: user.vet360_id) } # it 'calls update_address' do # expect_any_instance_of(VAProfile::V2::ContactInformation::Service).to receive(:update_address).and_call_original @@ -357,7 +357,7 @@ Flipper.disable(:va_v3_contact_information_service) end - let(:address) { build(:va_profile_address_v2, vet360_id: user.vet360_id) } + let(:address) { build(:va_profile_v3_address, vet360_id: user.vet360_id) } context 'with a 200 response' do it 'matches the address schema', :aggregate_failures do @@ -474,7 +474,7 @@ log_data = log.data expect(log_data['address_line1']).to eq(address.address_line1) expect(log_data['address_pou']).to eq(address.address_pou) - expect(log.error_class).to eq('VAProfile::Models::V2::Address ValidationError') + expect(log.error_class).to eq('VAProfile::Models::V3::Address ValidationError') end it 'matches the errors schema', :aggregate_failures do @@ -504,7 +504,7 @@ Flipper.disable(:va_v3_contact_information_service) end - let(:address) { build(:va_profile_address_v2, vet360_id: user.vet360_id) } + let(:address) { build(:va_profile_v3_address, vet360_id: user.vet360_id) } context 'with a 200 response' do it 'matches the email address schema', :aggregate_failures do @@ -534,7 +534,7 @@ end context 'with a validation key' do - let(:address) { build(:va_profile_address_v2, :override) } + let(:address) { build(:va_profile_v3_address, :override) } let(:frozen_time) { Time.zone.parse('2024-09-16T16:09:37.000Z') } before do @@ -579,7 +579,7 @@ context 'when effective_end_date is included' do let(:address) do - build(:va_profile_address_v2, effective_end_date: Time.now.utc.iso8601) + build(:va_profile_v3_address, effective_end_date: Time.now.utc.iso8601) end it 'effective_end_date is NOT included in the request body', :aggregate_failures do diff --git a/spec/support/va_profile/stub_vaprofile_user.rb b/spec/support/va_profile/stub_vaprofile_user.rb index 0083a45af5f..b088d88d3d4 100644 --- a/spec/support/va_profile/stub_vaprofile_user.rb +++ b/spec/support/va_profile/stub_vaprofile_user.rb @@ -2,7 +2,7 @@ require 'va_profile/v2/contact_information/service' require 'va_profile/v2/contact_information/person_response' -require 'va_profile/models/v2/address' +require 'va_profile/models/v3/address' require 'va_profile/models/telephone' # rubocop:disable Metrics/MethodLength @@ -13,8 +13,8 @@ def stub_vaprofile_user(person = nil) person ||= build( :person_v2, addresses: [ - build(:va_profile_address_v2, id: 577_127), - build(:va_profile_address_v2, address_pou: VAProfile::Models::V2::Address::CORRESPONDENCE, id: 124) + build(:va_profile_v3_address, id: 577_127), + build(:va_profile_v3_address, address_pou: VAProfile::Models::V3::Address::CORRESPONDENCE, id: 124) ], emails: [ build(:email, :contact_info_v2, id: 318_927) From 2ab41ada56dc1996a5128a5208206abe25040138 Mon Sep 17 00:00:00 2001 From: Brad Bergeron Date: Thu, 24 Oct 2024 17:22:39 -0400 Subject: [PATCH 2/9] Updates serializer used in determine method (#19076) --- modules/meb_api/app/controllers/meb_api/v0/forms_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/meb_api/app/controllers/meb_api/v0/forms_controller.rb b/modules/meb_api/app/controllers/meb_api/v0/forms_controller.rb index dbcfc15840d..1779051934e 100644 --- a/modules/meb_api/app/controllers/meb_api/v0/forms_controller.rb +++ b/modules/meb_api/app/controllers/meb_api/v0/forms_controller.rb @@ -121,7 +121,7 @@ def determine_response_and_serializer(claim_status_response, claimant_response) if claim_status_response.status == 200 [claim_status_response, ClaimStatusSerializer] else - [claimant_response, ClaimantSerializer] + [claimant_response, ToeClaimantInfoSerializer] end end From 0713aed5acb8bcf47de7973e7df71803225d3d58 Mon Sep 17 00:00:00 2001 From: mattwrightva <107576133+mattwrightva@users.noreply.github.com> Date: Thu, 24 Oct 2024 15:54:57 -0600 Subject: [PATCH 3/9] MHV-62901: Images request status API implemented (#19064) Co-authored-by: Matthew Wright --- lib/medical_records/bb_internal/client.rb | 10 +++++ .../v1/medical_records/imaging_controller.rb | 4 ++ modules/my_health/config/routes.rb | 1 + .../bb_internal/client_spec.rb | 19 ++++++++++ .../mr_client/bb_internal/study_status.yml | 38 +++++++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 spec/support/vcr_cassettes/mr_client/bb_internal/study_status.yml diff --git a/lib/medical_records/bb_internal/client.rb b/lib/medical_records/bb_internal/client.rb index 2f1c656edaf..ca80ab2060e 100644 --- a/lib/medical_records/bb_internal/client.rb +++ b/lib/medical_records/bb_internal/client.rb @@ -97,6 +97,16 @@ def get_dicom(study_id, header_callback, yielder) streaming_get(uri, token_headers, header_callback, yielder) end + ## + # check the status of a study job + # @return [Array] - [{ status: "COMPLETE", studyIdUrn: "111-1234567" percentComplete: 100, fileSize: "1.01 MB", + # startDate: 1729777818853, endDate}] + # + def get_study_status + response = perform(:get, "bluebutton/studyjob/#{session.patient_id}", nil, token_headers) + response.body + end + private ## diff --git a/modules/my_health/app/controllers/my_health/v1/medical_records/imaging_controller.rb b/modules/my_health/app/controllers/my_health/v1/medical_records/imaging_controller.rb index d5831b157c2..96177fae3e3 100644 --- a/modules/my_health/app/controllers/my_health/v1/medical_records/imaging_controller.rb +++ b/modules/my_health/app/controllers/my_health/v1/medical_records/imaging_controller.rb @@ -14,6 +14,10 @@ def request_download render_resource(bb_client.request_study(@study_id)) end + def request_status + render_resource(bb_client.request_status) + end + def images render_resource(bb_client.list_images(@study_id)) end diff --git a/modules/my_health/config/routes.rb b/modules/my_health/config/routes.rb index 23ce08fade2..74c9fa004e4 100644 --- a/modules/my_health/config/routes.rb +++ b/modules/my_health/config/routes.rb @@ -19,6 +19,7 @@ end resources :imaging, only: %i[index], defaults: { format: :json } do get 'request', on: :member, action: :request_download + get :status, on: :collection, action: :request_status get :images, on: :member get 'images/:series_id/:image_id', to: 'imaging#image', on: :member, as: :image get :dicom, on: :member diff --git a/spec/lib/medical_records/bb_internal/client_spec.rb b/spec/lib/medical_records/bb_internal/client_spec.rb index 4641a899305..0b69fcefad7 100644 --- a/spec/lib/medical_records/bb_internal/client_spec.rb +++ b/spec/lib/medical_records/bb_internal/client_spec.rb @@ -87,4 +87,23 @@ end end end + + describe '#get_study_status' do + it 'retrieves the status of all study jobs' do + VCR.use_cassette 'mr_client/bb_internal/study_status' do + study_job_list = client.get_study_status + + expect(study_job_list).to be_an(Array) + expect(study_job_list).not_to be_empty + + first_study_job = study_job_list.first + expect(first_study_job).to be_a(Hash) + + expect(first_study_job).to have_key('status') + expect(first_study_job['status']).to be_a(String) + expect(first_study_job).to have_key('studyIdUrn') + expect(first_study_job['studyIdUrn']).to be_a(String) + end + end + end end diff --git a/spec/support/vcr_cassettes/mr_client/bb_internal/study_status.yml b/spec/support/vcr_cassettes/mr_client/bb_internal/study_status.yml new file mode 100644 index 00000000000..ce39238a4dc --- /dev/null +++ b/spec/support/vcr_cassettes/mr_client/bb_internal/study_status.yml @@ -0,0 +1,38 @@ +--- +http_interactions: +- request: + method: get + uri: "/mhvapi/v1/bluebutton/studyjob/11382904" + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + Token: "" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: '' + headers: + Date: + - Thu, 24 Oct 2024 17:07:48 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: '[{"status":"COMPLETE","statusText":"100","studyIdUrn":"453-2487450","percentComplete":100,"fileSize":"7.67 + MB","fileSizeNumber":8041789,"startDate":1729777818853,"endDate":1729777843328},{"status":"COMPLETE","statusText":"100","studyIdUrn":"453-2487448","percentComplete":100,"fileSize":"253.91 + KB","fileSizeNumber":260001,"startDate":1729777819179,"endDate":1729777826103},{"status":"ERROR","statusText":"100","studyIdUrn":"451-72913365","percentComplete":100,"fileSize":"","fileSizeNumber":null,"startDate":1729777819016,"endDate":1729778734008}]' + recorded_at: Thu, 24 Oct 2024 17:07:48 GMT +recorded_with: VCR 6.3.1 From 801fdcf592a494dd90a25b1dc47f4dcaf1c6a8df Mon Sep 17 00:00:00 2001 From: Michael Marchand Date: Thu, 24 Oct 2024 16:37:58 -0600 Subject: [PATCH 4/9] Callback Handler for VANotify (#19024) * updates email_job, service and adds beginning of status_update with factory and testing * refines the delegate method with testing * rounds out the notifications factory * tests StatusUpdate in 2 scenarios * updates UserAccountJob * adds more test coverage for status_update and lints * lints and tests user_account_job * lints and tests service * lints email_job_spec * lint * applies suggested changes and lints * remove else branch when definining VANotify::Service w/o callback_options; updates tests * wraps a call to constantize in a rubocop disable, adds comment for reasoning * disables different rubocop cop * disables correct cop * attempts alternative way to constantize string * updates namespacing in helper class and lints --- .../app/services/va_notify/status_update.rb | 34 +++++++++ .../app/sidekiq/va_notify/email_job.rb | 5 +- .../app/sidekiq/va_notify/user_account_job.rb | 5 +- modules/va_notify/lib/va_notify/service.rb | 5 +- .../va_notify/spec/factories/notifications.rb | 31 ++++++++ modules/va_notify/spec/lib/service_spec.rb | 15 ++++ .../spec/services/status_update_spec.rb | 74 +++++++++++++++++++ .../va_notify/spec/sidekiq/email_job_spec.rb | 28 ++++++- .../spec/sidekiq/user_account_job_spec.rb | 31 +++++++- .../spec/support/helpers/callback_class.rb | 17 +++++ 10 files changed, 235 insertions(+), 10 deletions(-) create mode 100644 modules/va_notify/app/services/va_notify/status_update.rb create mode 100644 modules/va_notify/spec/factories/notifications.rb create mode 100644 modules/va_notify/spec/services/status_update_spec.rb create mode 100644 modules/va_notify/spec/support/helpers/callback_class.rb diff --git a/modules/va_notify/app/services/va_notify/status_update.rb b/modules/va_notify/app/services/va_notify/status_update.rb new file mode 100644 index 00000000000..9fe43eb5aaf --- /dev/null +++ b/modules/va_notify/app/services/va_notify/status_update.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module VANotify + class StatusUpdate + def delegate(notification_callback) + notification = VANotify::Notification.find_by(notification_id: notification_callback[:id]) + + # notification.callback is set by other teams, not user input + klass = constantized_class(notification.callback) + + if klass.respond_to?(:call) + begin + klass.call(notification) + rescue => e + Rails.logger.info(e.message) + end + else + begin + Rails.logger.info(message: 'The callback class does not implement #call') + ensure + Rails.logger.info(source: notification.source_location) + end + end + rescue => e + Rails.logger.info(source: notification.source_location, status: notification.status, error_message: e.message) + end + + private + + def constantized_class(class_name) + class_name.constantize + end + end +end diff --git a/modules/va_notify/app/sidekiq/va_notify/email_job.rb b/modules/va_notify/app/sidekiq/va_notify/email_job.rb index a9e3dac1fbf..f77d303f803 100644 --- a/modules/va_notify/app/sidekiq/va_notify/email_job.rb +++ b/modules/va_notify/app/sidekiq/va_notify/email_job.rb @@ -17,8 +17,9 @@ class EmailJob StatsD.increment("sidekiq.jobs.#{job_class.underscore}.retries_exhausted") end - def perform(email, template_id, personalisation = nil, api_key = Settings.vanotify.services.va_gov.api_key) - notify_client = VaNotify::Service.new(api_key) + def perform(email, template_id, personalisation = nil, api_key = Settings.vanotify.services.va_gov.api_key, + callback_options = nil) + notify_client = VaNotify::Service.new(api_key, callback_options) notify_client.send_email( { diff --git a/modules/va_notify/app/sidekiq/va_notify/user_account_job.rb b/modules/va_notify/app/sidekiq/va_notify/user_account_job.rb index 1f0631b4b9b..e2b97c3b040 100644 --- a/modules/va_notify/app/sidekiq/va_notify/user_account_job.rb +++ b/modules/va_notify/app/sidekiq/va_notify/user_account_job.rb @@ -21,10 +21,11 @@ def perform( user_account_id, template_id, personalisation = nil, - api_key = Settings.vanotify.services.va_gov.api_key + api_key = Settings.vanotify.services.va_gov.api_key, + callback_options = nil ) user_account = UserAccount.find(user_account_id) - notify_client = VaNotify::Service.new(api_key) + notify_client = VaNotify::Service.new(api_key, callback_options) notify_client.send_email( { diff --git a/modules/va_notify/lib/va_notify/service.rb b/modules/va_notify/lib/va_notify/service.rb index 19335491eb5..973c805c563 100644 --- a/modules/va_notify/lib/va_notify/service.rb +++ b/modules/va_notify/lib/va_notify/service.rb @@ -13,11 +13,12 @@ class Service < Common::Client::Base configuration VaNotify::Configuration - attr_reader :notify_client + attr_reader :notify_client, :callback_options - def initialize(api_key) + def initialize(api_key, callback_options = nil) overwrite_client_networking @notify_client ||= Notifications::Client.new(api_key, client_url) + @callback_options = callback_options rescue => e handle_error(e) end diff --git a/modules/va_notify/spec/factories/notifications.rb b/modules/va_notify/spec/factories/notifications.rb new file mode 100644 index 00000000000..d4b08d62793 --- /dev/null +++ b/modules/va_notify/spec/factories/notifications.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :notification, class: 'VANotify::Notification' do + notification_id { SecureRandom.uuid } + reference { nil } + to { 'email@email.com' } + status { + %w[temporary-failure permanent-failure technical-failure preferences-declined pending pending-virus-check + virus-scan-failed validation-failed failed created sending delivered sent].sample + } + completed_at { Time.zone.now } + sent_at { Time.zone.now } + notification_type { %w[Email sms].sample } + status_reason { + [ + 'Failed to deliver email due to hard bounce', + 'Temporarily failed to deliver email due to soft bounce', + 'Requested identifier not found in MPI correlation database', + 'Contact preferences set to false', + 'Mpi Profile not found for this identifier', + 'Unreachable destination handset', + 'No contact info found from VA Profile', + 'No recipient opt-in found for explicit preference' + ].sample + } + provider { %w[ses twilio pinpoint].sample } + source_location { 'SomeTeam' } + callback { 'SomeClass' } + end +end diff --git a/modules/va_notify/spec/lib/service_spec.rb b/modules/va_notify/spec/lib/service_spec.rb index 729841707ee..75705ce7e9b 100644 --- a/modules/va_notify/spec/lib/service_spec.rb +++ b/modules/va_notify/spec/lib/service_spec.rb @@ -69,6 +69,21 @@ expect(Notifications::Client).to have_received(:new).with(*parameters) end end + + it 'can receive callback_options' do + test_base_url = 'https://fakishapi.com' + callback_options = { + callback: 'TestTeam::TestClass', + metadata: 'optional_test_metadata' + } + with_settings(Settings.vanotify, + client_url: test_base_url) do + allow(Notifications::Client).to receive(:new).with(test_api_key, + test_base_url).and_return(notification_client) + service_object = VaNotify::Service.new(test_api_key, callback_options) + expect(service_object.callback_options).to eq(callback_options) + end + end end describe '#send_email', test_service: false do diff --git a/modules/va_notify/spec/services/status_update_spec.rb b/modules/va_notify/spec/services/status_update_spec.rb new file mode 100644 index 00000000000..2de3d55bf63 --- /dev/null +++ b/modules/va_notify/spec/services/status_update_spec.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +require 'rails_helper' +require_relative '../support/helpers/callback_class' + +describe VANotify::StatusUpdate do + subject { described_class.new } + + describe '#delegate' do + context 'notification with callback' do + it 'invokes callback class #call' do + notification_id = SecureRandom.uuid + create(:notification, notification_id:, callback: 'VANotify::OtherTeam::OtherForm') + allow(VANotify::OtherTeam::OtherForm).to receive(:call) + + provider_callback = { + id: notification_id + } + + subject.delegate(provider_callback) + + expect(VANotify::OtherTeam::OtherForm).to have_received(:call) + end + + it 'logs error message if #call fails' do + notification_id = SecureRandom.uuid + notification = create(:notification, notification_id:, callback: 'VANotify::OtherTeam::OtherForm') + provider_callback = { + id: notification_id + } + + allow(notification.callback.constantize).to receive(:call).with(notification).and_raise(StandardError, + 'Something went wrong') + + expect(Rails.logger).to receive(:info).with('Something went wrong') + + subject.delegate(provider_callback) + end + + it 'logs a message and source location if callback klass does not implement #call' do + notification_id = SecureRandom.uuid + notification = create(:notification, notification_id:, + callback: 'VANotify::NonCompliantModule::NonCompliantClass') + provider_callback = { + id: notification_id + } + + expect(Rails.logger).to receive(:info).with(message: 'The callback class does not implement #call') + expect(Rails.logger).to receive(:info).with(source: notification.source_location) + + subject.delegate(provider_callback) + end + end + + context 'notification without callback' do + it 'logs the status' do + notification_id = SecureRandom.uuid + notification = create(:notification, notification_id:, callback: nil) + + provider_callback = { + id: notification_id, + status: 'temporary-failure' + } + + expected_error_message = "undefined method `constantize' for nil" + + expect(Rails.logger).to receive(:info).with(source: notification.source_location, status: notification.status, + error_message: expected_error_message) + + subject.delegate(provider_callback) + end + end + end +end diff --git a/modules/va_notify/spec/sidekiq/email_job_spec.rb b/modules/va_notify/spec/sidekiq/email_job_spec.rb index db4a88354b0..9f247b36e6c 100644 --- a/modules/va_notify/spec/sidekiq/email_job_spec.rb +++ b/modules/va_notify/spec/sidekiq/email_job_spec.rb @@ -19,7 +19,7 @@ describe '#perform' do it 'sends an email using the template id' do client = double - expect(VaNotify::Service).to receive(:new).with(Settings.vanotify.services.va_gov.api_key).and_return(client) + expect(VaNotify::Service).to receive(:new).with(Settings.vanotify.services.va_gov.api_key, nil).and_return(client) expect(client).to receive(:send_email).with( { @@ -36,7 +36,7 @@ it 'can use non-default api key' do client = double api_key = 'test-yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy-zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz' - expect(VaNotify::Service).to receive(:new).with(api_key).and_return(client) + expect(VaNotify::Service).to receive(:new).with(api_key, nil).and_return(client) expect(client).to receive(:send_email).with( { @@ -72,6 +72,30 @@ end end end + + context 'with optional callback support' do + it 'can accept callback options' do + client = double + api_key = Settings.vanotify.services.va_gov.api_key + callback_options = { + callback: 'TestTeam::TestClass', + metadata: 'optional_test_metadata' + } + + expect(VaNotify::Service).to receive(:new).with(api_key, callback_options).and_return(client) + + expect(client).to receive(:send_email).with( + { + email_address: email, + template_id:, + personalisation: {} + } + ) + personalization = {} + + described_class.new.perform(email, template_id, personalization, api_key, callback_options) + end + end end describe 'when job has failed' do diff --git a/modules/va_notify/spec/sidekiq/user_account_job_spec.rb b/modules/va_notify/spec/sidekiq/user_account_job_spec.rb index 27285bad680..a2e5f734680 100644 --- a/modules/va_notify/spec/sidekiq/user_account_job_spec.rb +++ b/modules/va_notify/spec/sidekiq/user_account_job_spec.rb @@ -20,7 +20,7 @@ describe '#perform' do it 'sends an email using the template id' do client = double - expect(VaNotify::Service).to receive(:new).with(Settings.vanotify.services.va_gov.api_key).and_return(client) + expect(VaNotify::Service).to receive(:new).with(Settings.vanotify.services.va_gov.api_key, nil).and_return(client) expect(client).to receive(:send_email).with( { @@ -40,7 +40,7 @@ it 'can use non-default api key' do client = double api_key = 'test-yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy-zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz' - expect(VaNotify::Service).to receive(:new).with(api_key).and_return(client) + expect(VaNotify::Service).to receive(:new).with(api_key, nil).and_return(client) expect(client).to receive(:send_email).with( { @@ -82,6 +82,33 @@ end end end + + context 'with optional callback support' do + it 'can accept callback options' do + client = double + api_key = Settings.vanotify.services.va_gov.api_key + callback_options = { + callback: 'TestTeam::TestClass', + metadata: 'optional_test_metadata' + } + + expect(VaNotify::Service).to receive(:new).with(api_key, callback_options).and_return(client) + + expect(client).to receive(:send_email).with( + { + recipient_identifier: { + id_value: icn, + id_type: 'ICN' + }, + template_id:, + personalisation: {} + } + ) + personalization = {} + + described_class.new.perform(user_account.id, template_id, personalization, api_key, callback_options) + end + end end describe 'when job has failed' do diff --git a/modules/va_notify/spec/support/helpers/callback_class.rb b/modules/va_notify/spec/support/helpers/callback_class.rb new file mode 100644 index 00000000000..99506738da9 --- /dev/null +++ b/modules/va_notify/spec/support/helpers/callback_class.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module VANotify::OtherTeam + class OtherForm + def self.call(_notification) + true + end + end +end + +module VANotify::NonCompliantModule + class NonCompliantClass + def self.not_call(_notification) + false + end + end +end From c34392656f696f82aefb0d4aceaea3552f43b9f5 Mon Sep 17 00:00:00 2001 From: Penelope Lischer <102491809+penny-lischer@users.noreply.github.com> Date: Thu, 24 Oct 2024 16:21:12 -0700 Subject: [PATCH 5/9] 95727 - Issue with data validation in submission `creditorName` and ` spouseFullName/last` [FSR] (#19058) --- ...nstallment_contracts_other_debts_calculator.rb | 2 +- .../personal_data_calculator.rb | 2 +- ...lment_contracts_other_debts_calculator_spec.rb | 15 +++++++++++++++ .../personal_data_calculator_spec.rb | 8 ++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/modules/debts_api/lib/debts_api/v0/fsr_form_transform/installment_contracts_other_debts_calculator.rb b/modules/debts_api/lib/debts_api/v0/fsr_form_transform/installment_contracts_other_debts_calculator.rb index 1ada3a3e619..63452f7e16c 100644 --- a/modules/debts_api/lib/debts_api/v0/fsr_form_transform/installment_contracts_other_debts_calculator.rb +++ b/modules/debts_api/lib/debts_api/v0/fsr_form_transform/installment_contracts_other_debts_calculator.rb @@ -42,7 +42,7 @@ def get_totals_data def get_installment_or_other_debt_data_for(item) data = { 'purpose' => item['purpose'], - 'creditorName' => item['creditor_name'], + 'creditorName' => item['creditor_name'] || '', 'originalAmount' => format_installment_debt_number(item['original_amount']), 'unpaidBalance' => format_installment_debt_number(item['unpaid_balance']), 'amountDueMonthly' => item['amount_due_monthly'], diff --git a/modules/debts_api/lib/debts_api/v0/fsr_form_transform/personal_data_calculator.rb b/modules/debts_api/lib/debts_api/v0/fsr_form_transform/personal_data_calculator.rb index 48b24d05260..1d8e0deaa50 100644 --- a/modules/debts_api/lib/debts_api/v0/fsr_form_transform/personal_data_calculator.rb +++ b/modules/debts_api/lib/debts_api/v0/fsr_form_transform/personal_data_calculator.rb @@ -102,7 +102,7 @@ def spouse_full_name { 'first' => @personal_data['spouse_full_name']['first'], 'middle' => @personal_data['spouse_full_name']['middle'] || '', - 'last' => @personal_data['spouse_full_name']['last'] + 'last' => @personal_data['spouse_full_name']['last'] || '' } else { diff --git a/modules/debts_api/spec/lib/debt_api/v0/fsr_form_transform/installment_contracts_other_debts_calculator_spec.rb b/modules/debts_api/spec/lib/debt_api/v0/fsr_form_transform/installment_contracts_other_debts_calculator_spec.rb index 9b93bc20e0b..d7948d7455f 100644 --- a/modules/debts_api/spec/lib/debt_api/v0/fsr_form_transform/installment_contracts_other_debts_calculator_spec.rb +++ b/modules/debts_api/spec/lib/debt_api/v0/fsr_form_transform/installment_contracts_other_debts_calculator_spec.rb @@ -12,6 +12,12 @@ get_fixture_absolute('modules/debts_api/spec/fixtures/pre_submission_fsr/post_transform') end + let(:transformer_data) do + transformer = described_class.new(pre_form_data) + transformer.get_data + transformer.get_totals_data + end + def get_data transformer = described_class.new(pre_form_data) @data = transformer.get_data @@ -32,6 +38,15 @@ def get_data expected_installment_contracts_other_debts_data = post_form_data['totalOfInstallmentContractsAndOtherDebts'] expect(expected_installment_contracts_other_debts_data).to eq(@total_data) end + + it 'returns empty string for creditorName' do + pre_form_data['installment_contracts'].first['creditor_name'] = nil + calculator = described_class.new(pre_form_data) + calculator_data = calculator.get_data + + creditor_names = calculator_data.pluck('creditorName') + expect(creditor_names).to eq(['', '']) + end end end end diff --git a/modules/debts_api/spec/lib/debt_api/v0/fsr_form_transform/personal_data_calculator_spec.rb b/modules/debts_api/spec/lib/debt_api/v0/fsr_form_transform/personal_data_calculator_spec.rb index b73d1020995..2ca73978f87 100644 --- a/modules/debts_api/spec/lib/debt_api/v0/fsr_form_transform/personal_data_calculator_spec.rb +++ b/modules/debts_api/spec/lib/debt_api/v0/fsr_form_transform/personal_data_calculator_spec.rb @@ -22,6 +22,14 @@ expect(expected_personal_data).to eq(transformer_data) end + it 'returns empty string for spouseFullName/last' do + pre_transform_fsr_form_data['personal_data']['spouse_full_name']['last'] = nil + calculator = described_class.new(pre_transform_fsr_form_data) + calculator_data = calculator.get_personal_data + + expect(calculator_data['spouseFullName']['last']).to eq('') + end + it 'returns empty string for addressLine2 and addressLine3' do pre_transform_fsr_form_data['personal_data']['veteran_contact_information']['address']['address_line2'] = nil calculator = described_class.new(pre_transform_fsr_form_data) From 048a7a39d9f6cb84f11aaea93c031919ed6f920b Mon Sep 17 00:00:00 2001 From: Mitch Saltykov Date: Wed, 23 Oct 2024 09:56:31 -0400 Subject: [PATCH 6/9] convert sentry logs to messages for ease of tracking --- .../concerns/form_attachment_create.rb | 24 ++++++++++++++++--- spec/concerns/form_attachment_create_spec.rb | 24 ++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/app/controllers/concerns/form_attachment_create.rb b/app/controllers/concerns/form_attachment_create.rb index 13b0c08c69e..484aff2fee5 100644 --- a/app/controllers/concerns/form_attachment_create.rb +++ b/app/controllers/concerns/form_attachment_create.rb @@ -41,21 +41,39 @@ def validate_file_upload_class! raise Common::Exceptions::InvalidFieldValue.new('file_data', filtered_params[:file_data].class.name) end rescue => e - log_exception_to_sentry(e, { context: 'FAC_validate', class: filtered_params[:file_data].class.name }) + log_message_to_sentry( + 'form attachment error 1', + :info, + phase: 'FAC_validate', + klass: filtered_params[:file_data].class.name, + exception: e.message + ) raise e end def save_attachment_to_cloud! form_attachment.set_file_data!(filtered_params[:file_data], filtered_params[:password]) rescue => e - log_exception_to_sentry(e, { context: 'FAC_cloud' }) + log_message_to_sentry( + 'form attachment error 2', + :info, + phase: 'FAC_cloud', + exception: e.message + ) raise e end def save_attachment_to_db! form_attachment.save! rescue => e - log_exception_to_sentry(e, { context: 'FAC_db', errors: form_attachment.errors }) + log_message_to_sentry( + 'form attachment error 3', + :info, + phase: 'FAC_db', + errors: form_attachment.errors, + exception: e.message + ) + raise e end diff --git a/spec/concerns/form_attachment_create_spec.rb b/spec/concerns/form_attachment_create_spec.rb index 499362f8c03..864381a8c31 100644 --- a/spec/concerns/form_attachment_create_spec.rb +++ b/spec/concerns/form_attachment_create_spec.rb @@ -79,7 +79,13 @@ def serializer_klass klass: 'String', debug_timestamp: anything ) - expect(@controller).to receive(:log_exception_to_sentry).twice + expect(@controller).to receive(:log_message_to_sentry).with( + 'form attachment error 1', + :info, + phase: 'FAC_validate', + klass: 'String', + exception: 'Invalid field value' + ) post(:create, params: { hca_attachment: { file_data: } }) end @@ -95,7 +101,12 @@ def serializer_klass klass: 'ActionDispatch::Http::UploadedFile', debug_timestamp: anything ) - expect(@controller).to receive(:log_exception_to_sentry).twice + expect(@controller).to receive(:log_message_to_sentry).with( + 'form attachment error 2', + :info, + phase: 'FAC_cloud', + exception: 'Unprocessable Entity' + ) form_attachment = double(HCAAttachment) expect(HCAAttachment).to receive(:new) { form_attachment } @@ -116,12 +127,19 @@ def serializer_klass klass: 'ActionDispatch::Http::UploadedFile', debug_timestamp: anything ) - expect(@controller).to receive(:log_exception_to_sentry) + expect(@controller).to receive(:log_message_to_sentry).with( + 'form attachment error 3', + :info, + phase: 'FAC_db', + errors: 'error text', + exception: 'Record invalid' + ) form_attachment = double(HCAAttachment) expect(HCAAttachment).to receive(:new) { form_attachment } expect(form_attachment).to receive(:set_file_data!) expect(form_attachment).to receive(:save!).and_raise(ActiveRecord::RecordInvalid) + expect(form_attachment).to receive(:errors).and_return('error text') post(:create, params: { hca_attachment: { file_data: } }) end From f401602f63122729f0f7f5062e91a2010c0481bf Mon Sep 17 00:00:00 2001 From: mattwrightva <107576133+mattwrightva@users.noreply.github.com> Date: Fri, 25 Oct 2024 08:53:36 -0600 Subject: [PATCH 7/9] Mhv 63375 ccd generate and download (#19059) * MHV-42363 Initial cut at radiology imaging * MHV-42363 More work on imaging * MHV-42363 Imaging work mostly complete * MHV-42363 Capture headers for DICOM * MHV-42363 Refactored controller * MHV-42363 Added spec tests for new client functions * MHV-42363 BBInternal now expects ICN * MHV-42363 Fixed header pass-through * MHV-42363 Fixed data for broken spec test * MHV-42363 Removed "new_episodes" * MHV-63375: generate and download ccd work done * MHV-63375: Shortened comment * MHV-63375: Added new routes and moved controller --------- Co-authored-by: Mike Moyer Co-authored-by: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Co-authored-by: Matthew Wright --- lib/medical_records/bb_internal/client.rb | 20 + .../v1/medical_records/ccd_controller.rb | 24 + modules/my_health/config/routes.rb | 6 + .../bb_internal/client_spec.rb | 30 ++ .../mr_client/bb_internal/download_ccd.yml | 411 ++++++++++++++++++ .../mr_client/bb_internal/generate_ccd.yml | 36 ++ 6 files changed, 527 insertions(+) create mode 100644 modules/my_health/app/controllers/my_health/v1/medical_records/ccd_controller.rb create mode 100644 spec/support/vcr_cassettes/mr_client/bb_internal/download_ccd.yml create mode 100644 spec/support/vcr_cassettes/mr_client/bb_internal/generate_ccd.yml diff --git a/lib/medical_records/bb_internal/client.rb b/lib/medical_records/bb_internal/client.rb index ca80ab2060e..95478a5490e 100644 --- a/lib/medical_records/bb_internal/client.rb +++ b/lib/medical_records/bb_internal/client.rb @@ -98,6 +98,26 @@ def get_dicom(study_id, header_callback, yielder) end ## + # @param icn - user icn + # @param last_name - user last name + # @return JSON [{ dateGenerated, status, patientId }] + # + def get_generate_ccd(icn, last_name) + response = perform(:get, "bluebutton/healthsummary/#{icn}/#{last_name}/xml", nil, token_headers) + response.body + end + + ## + # @param date - receieved from get_generate_ccd call property dateGenerated (e.g. 2024-10-18T09:55:58.000-0400) + # @return - Continuity of Care Document in XML format + # + def get_download_ccd(date) + token_headers['Accept'] = 'application/xml' + + response = perform(:get, "bluebutton/healthsummary/#{date}/fileFormat/XML/ccdType/XML", nil, token_headers) + response.body + end + # check the status of a study job # @return [Array] - [{ status: "COMPLETE", studyIdUrn: "111-1234567" percentComplete: 100, fileSize: "1.01 MB", # startDate: 1729777818853, endDate}] diff --git a/modules/my_health/app/controllers/my_health/v1/medical_records/ccd_controller.rb b/modules/my_health/app/controllers/my_health/v1/medical_records/ccd_controller.rb new file mode 100644 index 00000000000..94edee21206 --- /dev/null +++ b/modules/my_health/app/controllers/my_health/v1/medical_records/ccd_controller.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module MyHealth + module V1 + module MedicalRecords + class CcdController < MrController + # Generates a CCD + # @return [Array] of objects with CCDs generated date and status (COMPLETE or not) + def generate + resource = bb_client.get_generate_ccd(@current_user.icn, @current_user.last_name) + render json: resource.to_json + end + + # Downloads the CCD once it has been generated + # @param generated_datetime [String] date receieved from get_generate_ccd call property dateGenerated + # @return [XML] Continuity of Care Document + def download + resource = bb_client.get_download_ccd(generated_datetime) + send_data resource, type: 'application/xml' + end + end + end + end +end diff --git a/modules/my_health/config/routes.rb b/modules/my_health/config/routes.rb index 74c9fa004e4..7f83bb5bc49 100644 --- a/modules/my_health/config/routes.rb +++ b/modules/my_health/config/routes.rb @@ -17,6 +17,12 @@ resources :session, only: %i[create], controller: 'mr_session', defaults: { format: :json } do get :status, on: :collection end + resources :ccd, only: [] do + collection do + get :generate, to: 'ccd#generate' + get :download, to: 'ccd#download' + end + end resources :imaging, only: %i[index], defaults: { format: :json } do get 'request', on: :member, action: :request_download get :status, on: :collection, action: :request_status diff --git a/spec/lib/medical_records/bb_internal/client_spec.rb b/spec/lib/medical_records/bb_internal/client_spec.rb index 0b69fcefad7..d5329777510 100644 --- a/spec/lib/medical_records/bb_internal/client_spec.rb +++ b/spec/lib/medical_records/bb_internal/client_spec.rb @@ -88,6 +88,36 @@ end end + describe '#get_generate_ccd' do + it 'requests a CCD be generated and returns the correct structure' do + VCR.use_cassette 'mr_client/bb_internal/generate_ccd' do + ccd_list = client.get_generate_ccd(client.session.icn, 'DOE') + + expect(ccd_list).to be_an(Array) + expect(ccd_list).not_to be_empty + + first_ccd = ccd_list.first + expect(first_ccd).to be_a(Hash) + expect(first_ccd).to have_key('dateGenerated') + expect(first_ccd['dateGenerated']).to be_a(String) + + expect(first_ccd).to have_key('status') + expect(first_ccd['status']).to be_a(String) + end + end + end + + describe '#get_download_ccd' do + it 'retrieves a previously generated CCD as XML' do + VCR.use_cassette 'mr_client/bb_internal/download_ccd' do + ccd = client.get_download_ccd('2024-10-23T12:42:48.000-0400') + + expect(ccd).to be_a(String) + expect(ccd).to include('/mhvapi/v1/bluebutton/healthsummary/2024-10-23T12:42:48.000-0400/fileFormat/XML/ccdType/XML" + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/xml + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + Token: "" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: '' + headers: + Date: + - Wed, 23 Oct 2024 20:20:59 GMT + Content-Type: + - text/xml + Content-Length: + - '32663' + Expires: + - "-1" + Cache-Control: + - no-cache + Content-Disposition: + - attachment; filename=mhv_VA_CCD_IPOACEVEDA_20241023_1242.xml + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: "\n\nVA Continuity of Care Document (CCD)4002 + Crutchfield StRichmondVA23225-4755IPOACEVEDADEWAYNEDEANMMarriedNazareneDeclined to AnswerNot Hispanic or LatinoDepartment of + Veterans Affairs (VA)Department + of Veterans Affairs (VA)810 + Vermont Avenue NWWashingtonDC20420USPrimary Care ProviderWVDIXSON, + JESSIPOTEST 1
Insurance Providers: All on record + at VANo Data Provided for This Section
Advance Directives: All on record + at VANo Data Provided + for This Section
Allergies and Adverse Reactions (ADRs): + All on record at VANo Data + Provided for This Section
Encounters: + Outpatient Encounters with NotesNo Data Provided for This Section
Functional Status: Functional Independence + Measurement (FIM) ScoresNo Data Provided for This Section
Medications: VA Dispensed and Non-VA Documented + (Obtained Outside VA)No + Data Provided for This Section
Immunizations: All on record at VANo Data Provided + for This Section
Procedures: + Surgical Procedures with NotesNo + Data Provided for This Section
Plan of + Treatment: Future Appointments and Active/Pending OrdersNo Data + Provided for This Section
Problems (Conditions): All on record at VANo Data Provided for This Section
Results: Chemistry and HematologyNo Data Provided + for This Section
Social History: All on record at VANo + Data Provided for This Section
Vital Signs\n The + included list of inpatient and outpatient Vital Signs is from the last 12 + months and includes a maximum of the 5 most recent sets of vital sign values. + If more than one set of vitals was taken on the same date, only the most recent + set is populated for that date. The data comes from all VA treatment facilities. + Vital Sign information from the new VA electronic health record is not included.\n\t\t\t\t\t\t\t\t\t\t\t
Date/TimeTemperaturePulseBlood + PressureRespiratory RateSP02PainHeightWeightBody + Mass IndexSource
Aug 29, 2024 12:57 + PM99 77 22 CHEYENNE VAMC
Vital + Sign Observation Text Not Available
TEMPERATUREPULSERESPIRATION
Consult NotesConsult + Notes\n The + included Consult Notes are from the last 18 months, are available thirty-six + (36) hours after completion, and include a maximum of the 5 most recent notes. + The data comes from all VA treatment facilities. Note that Compensation & + Pension Notes are available 30 days after completion. Consult Notes (including + Compensation and Pension exam notes) from the new VA electronic health record + are not included.\n\t\t\t\t\t\t\t\t\t\t
Date/TimeConsult + Note with TextProviderSource
Aug 21, 2024 12:00 PMEDUCATION:
LOCAL TITLE: NUTRITION CLASS - SATP EDUCATION CONSULT REPORT
STANDARD + TITLE: NUTRITION EDUCATION NOTE
DATE OF NOTE: + AUG 21, 2024@12:00 ENTRY DATE: AUG 21, 2024@14:38:20
AUTHOR: + GOODMAN,KEOLA EXP COSIGNER:
URGENCY: + \ STATUS: COMPLETED

VistA Imaging - Scanned Document


*** + SCANNED DOCUMENT ***
SIGNATURE NOT REQUIRED


Electronically Filed: 08/21/2024
by: + KEOLA GOODMAN




GOODMAN,KEOLACHEYENNE + VAMC
History and Physical + NotesNo Data Provided for This Section
Discharge + SummariesNo Data Provided for This Section
Radiology + ReportsNo Data Provided for This Section
Pathology + ReportsNo Data Provided for This Section
Clinical + Procedure NotesNo Data Provided for This Section
\n" + recorded_at: Wed, 23 Oct 2024 20:20:59 GMT +recorded_with: VCR 6.3.1 diff --git a/spec/support/vcr_cassettes/mr_client/bb_internal/generate_ccd.yml b/spec/support/vcr_cassettes/mr_client/bb_internal/generate_ccd.yml new file mode 100644 index 00000000000..96bb7c54d51 --- /dev/null +++ b/spec/support/vcr_cassettes/mr_client/bb_internal/generate_ccd.yml @@ -0,0 +1,36 @@ +--- +http_interactions: +- request: + method: get + uri: "/mhvapi/v1/bluebutton/healthsummary/1012740022V620959/DOE/xml" + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + Token: "" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: '' + headers: + Date: + - Wed, 23 Oct 2024 20:04:00 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: '[{"dateGenerated":"2024-10-23T12:42:48.000-0400","status":"COMPLETE","patientId":"1012740022V620959"},{"dateGenerated":"2024-10-22T15:10:37.000-0400","status":"COMPLETE","patientId":"1012740022V620959"}]' + recorded_at: Wed, 23 Oct 2024 20:04:00 GMT +recorded_with: VCR 6.3.1 From e2e4a758f52142b3dbd4b540df0bf537626d0a31 Mon Sep 17 00:00:00 2001 From: Rebecca Tolmach <10993987+rmtolmach@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:05:36 -0400 Subject: [PATCH 8/9] Fix code scanning alert no. 859: Deserialization of user-controlled data (#19080) Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- modules/check_in/app/services/travel_claim/service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/check_in/app/services/travel_claim/service.rb b/modules/check_in/app/services/travel_claim/service.rb index 7fa01e25333..963ea007f9b 100644 --- a/modules/check_in/app/services/travel_claim/service.rb +++ b/modules/check_in/app/services/travel_claim/service.rb @@ -49,7 +49,7 @@ def token resp = client.token - Oj.load(resp.body)&.fetch('access_token').tap do |access_token| + Oj.safe_load(resp.body)&.fetch('access_token').tap do |access_token| redis_client.save_token(token: access_token) end end From ab8262972fe4de27829bc23f80ad07a5636a1dfd Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Fri, 25 Oct 2024 10:11:37 -0500 Subject: [PATCH 9/9] chore: Bump Code Checks to 32 core (#19089) --- .github/workflows/code_checks.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml index 2c333da3b67..bce18493148 100644 --- a/.github/workflows/code_checks.yml +++ b/.github/workflows/code_checks.yml @@ -13,7 +13,7 @@ jobs: env: BUNDLE_ENTERPRISE__CONTRIBSYS__COM: ${{ secrets.BUNDLE_ENTERPRISE__CONTRIBSYS__COM }} permissions: write-all - runs-on: ubuntu-16-cores-latest + runs-on: ubuntu-32-cores-latest steps: - uses: actions/checkout@v4 @@ -63,7 +63,7 @@ jobs: DOCKER_BUILDKIT: 1 COMPOSE_DOCKER_CLI_BUILD: 1 permissions: write-all - runs-on: ubuntu-16-cores-latest + runs-on: ubuntu-32-cores-latest steps: - uses: actions/checkout@v4 @@ -131,13 +131,13 @@ jobs: max_attempts: 3 command: | docker compose -f docker-compose.test.yml run web bash \ - -c "CI=true RAILS_ENV=test DISABLE_BOOTSNAP=true bundle exec parallel_test -n 13 -e 'bin/rails db:reset'" + -c "CI=true RAILS_ENV=test DISABLE_BOOTSNAP=true bundle exec parallel_test -n 24 -e 'bin/rails db:reset'" - name: Run Specs timeout-minutes: 20 run: | docker compose -f docker-compose.test.yml run web bash \ - -c "CI=true DISABLE_BOOTSNAP=true bundle exec parallel_rspec spec/ modules/ -n 13 -o '--color --tty'" + -c "CI=true DISABLE_BOOTSNAP=true bundle exec parallel_rspec spec/ modules/ -n 24 -o '--color --tty'" - name: Upload Coverage Report uses: actions/upload-artifact@v4