From 56b7d41068eb06c1663d764f4deca2c6f5faecb2 Mon Sep 17 00:00:00 2001 From: jvcAdHoc <144135615+jvcAdHoc@users.noreply.github.com> Date: Thu, 25 Apr 2024 11:27:20 -0400 Subject: [PATCH] update vsoreloader to correctly upsert organization data (#16470) --- .../app/sidekiq/veteran/vso_reloader.rb | 2 +- .../spec/sidekiq/veteran/vso_reloader_spec.rb | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/veteran/app/sidekiq/veteran/vso_reloader.rb b/modules/veteran/app/sidekiq/veteran/vso_reloader.rb index 132688277c4..0f11aa7b51f 100644 --- a/modules/veteran/app/sidekiq/veteran/vso_reloader.rb +++ b/modules/veteran/app/sidekiq/veteran/vso_reloader.rb @@ -56,7 +56,7 @@ def reload_vso_reps state: vso_rep['Org State'] } end.compact.uniq - Veteran::Service::Organization.import(vso_orgs, on_duplicate_key_ignore: true) + Veteran::Service::Organization.import(vso_orgs, on_duplicate_key_update: %i[name phone state]) vso_reps end diff --git a/modules/veteran/spec/sidekiq/veteran/vso_reloader_spec.rb b/modules/veteran/spec/sidekiq/veteran/vso_reloader_spec.rb index e5d826d9754..1c5728b7e9c 100644 --- a/modules/veteran/spec/sidekiq/veteran/vso_reloader_spec.rb +++ b/modules/veteran/spec/sidekiq/veteran/vso_reloader_spec.rb @@ -46,6 +46,29 @@ end end + context 'existing organizations' do + let(:org) do + create(:organization, poa: '091', name: 'Testing', phone: '222-555-5555', state: 'ZZ', city: 'New York') + end + + it 'only updates name, phone, and state' do + VCR.use_cassette('veteran/ogc_vso_rep_data') do + expect(org.name).to eq('Testing') + expect(org.phone).to eq('222-555-5555') + expect(org.state).to eq('ZZ') + expect(org.city).to eq('New York') + + Veteran::VSOReloader.new.reload_vso_reps + org.reload + + expect(org.name).to eq('African American PTSD Association') + expect(org.phone).to eq('253-589-0766') + expect(org.state).to eq('WA') + expect(org.city).to eq('New York') + end + end + end + describe "storing a VSO's middle initial" do it 'stores the middle initial if it exists' do VCR.use_cassette('veteran/ogc_vso_rep_data') do