Skip to content

Commit

Permalink
update vsoreloader to correctly upsert organization data (#16470)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvcAdHoc committed Apr 25, 2024
1 parent 8a4a934 commit 56b7d41
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/veteran/app/sidekiq/veteran/vso_reloader.rb
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions modules/veteran/spec/sidekiq/veteran/vso_reloader_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 56b7d41

Please sign in to comment.