Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[81300] Update VSOReloader to correctly upsert organization data #16470

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/veteran/app/sidekiq/veteran/vso_reloader.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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')
Comment on lines +64 to +66
Copy link
Contributor Author

@jvcAdHoc jvcAdHoc Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these values come from the cassette

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
Loading