-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patient relationship failures (#19887)
- Loading branch information
1 parent
620033b
commit e459d58
Showing
6 changed files
with
248 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
modules/vaos/spec/request/v2/relationships_request_spec.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'relationships', :skip_mvi, type: :request do | ||
before do | ||
sign_in_as(current_user) | ||
allow_any_instance_of(VAOS::UserService).to receive(:session).and_return('stubbed_token') | ||
allow(Flipper).to receive(:enabled?).and_return(true) | ||
end | ||
|
||
let(:inflection_header) { { 'X-Key-Inflection' => 'camel' } } | ||
|
||
context 'loa3 user' do | ||
let(:current_user) { build(:user, :vaos) } | ||
|
||
describe 'GET relationships' do | ||
let(:params) { { clinical_service_id: 'primaryCare', facility_id: '100' } } | ||
|
||
context 'patient relationships' do | ||
it 'successfully returns patient relationships' do | ||
VCR.use_cassette('vaos/v2/relationships/get_relationships', | ||
match_requests_on: %i[method path query]) do | ||
get '/vaos/v2/relationships?clinicalServiceId=primaryCare&facilityId=100', params:, | ||
headers: inflection_header | ||
expect(response).to have_http_status(:ok) | ||
|
||
relationships = JSON.parse(response.body)['data'] | ||
expect(relationships).not_to be_nil | ||
expect(relationships.length).to eq(4) | ||
relationships.each do |relationship| | ||
expect(relationship['type']).to eq('relationship') | ||
end | ||
|
||
meta = JSON.parse(response.body)['meta'] | ||
expect(meta['failures']).to eq([]) | ||
end | ||
end | ||
|
||
it 'returns patient relationships containing partial errors' do | ||
VCR.use_cassette('vaos/v2/relationships/get_relationships_partial_error', | ||
match_requests_on: %i[method path query]) do | ||
allow(Rails.logger).to receive(:info).at_least(:once) | ||
get '/vaos/v2/relationships?clinicalServiceId=primaryCare&facilityId=100', params:, | ||
headers: inflection_header | ||
expect(response).to have_http_status(:ok) | ||
|
||
relationships = JSON.parse(response.body)['data'] | ||
expect(relationships).not_to be_nil | ||
expect(relationships.length).to eq(4) | ||
relationships.each do |relationship| | ||
expect(relationship['type']).to eq('relationship') | ||
end | ||
|
||
meta = JSON.parse(response.body)['meta'] | ||
expect(meta['failures'].length).to eq(1) | ||
expect(meta['failures'][0]['system']).to eq('CFA') | ||
expect(meta['failures'][0]['id']).to eq('id-string') | ||
expect(meta['failures'][0]['status']).to eq('status-string') | ||
expect(meta['failures'][0]['detail']).to eq('detail-string') | ||
expect(meta['failures'][0]['traceId']).to eq('traceId-string') | ||
expect(meta['failures'][0]['code']).to eq(0) | ||
|
||
expect(Rails.logger).to have_received(:info).at_least(:once) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
3 changes: 2 additions & 1 deletion
3
spec/support/vcr_cassettes/vaos/v2/relationships/get_relationships.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
136 changes: 136 additions & 0 deletions
136
spec/support/vcr_cassettes/vaos/v2/relationships/get_relationships_partial_error.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.