index
int64 0
0
| repo_id
stringclasses 829
values | file_path
stringlengths 34
254
| content
stringlengths 6
5.38M
|
|---|---|---|---|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/gi/institution_programs_spec.rb
|
# frozen_string_literal: false
require 'rails_helper'
RSpec.describe 'V0::GI::InstitutionPrograms', type: :request do
include SchemaMatchers
it 'responds to GET #search with bad encoding' do
VCR.use_cassette('gi_client/gets_institution_program_search_results') do
get '/v0/gi/institution_programs/search?name=%ADcode'
end
expect(response).to be_successful
end
it 'responds to GET #autocomplete' do
VCR.use_cassette('gi_client/gets_a_list_of_institution_program_autocomplete_suggestions') do
get '/v0/gi/institution_programs/autocomplete?term=code'
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_response_schema('gi/autocomplete')
end
it 'responds to GET #autocomplete when camel-inflected' do
VCR.use_cassette('gi_client/gets_a_list_of_institution_program_autocomplete_suggestions') do
get '/v0/gi/institution_programs/autocomplete?term=code', headers: { 'X-Key-Inflection' => 'camel' }
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_camelized_response_schema('gi/autocomplete')
end
it 'responds to GET #autocomplete with bad encoding' do
VCR.use_cassette('gi_client/gets_a_list_of_institution_program_autocomplete_suggestions') do
get '/v0/gi/institution_programs/autocomplete?term=%ADcode'
end
expect(response).to be_successful
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/gi/calculator_constants_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::GI::CalculatorConstants', type: :request do
include SchemaMatchers
it 'responds to GET #index' do
VCR.use_cassette('gi_client/gets_the_calculator_constants') do
get '/v0/gi/calculator_constants/'
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_response_schema('gi/calculator_constants')
end
it 'responds to GET #index when camel-inflected' do
VCR.use_cassette('gi_client/gets_the_calculator_constants') do
get '/v0/gi/calculator_constants/', headers: { 'X-Key-Infelction' => 'camel' }
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_camelized_response_schema('gi/calculator_constants')
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/gi/institutions_spec.rb
|
# frozen_string_literal: false
require 'rails_helper'
RSpec.describe 'V0::GI::Institutions', type: :request do
include SchemaMatchers
let(:inflection_header) { { 'X-Key-Inflection' => 'camel' } }
it 'responds to GET #search' do
VCR.use_cassette('gi_client/gets_institution_search_results') do
get '/v0/gi/institutions/search?name=illinois'
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_response_schema('gi/institutions')
end
it 'responds to GET #search when camel-inflected' do
VCR.use_cassette('gi_client/gets_institution_search_results') do
get '/v0/gi/institutions/search?name=illinois', headers: inflection_header
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_camelized_response_schema('gi/institutions')
end
it 'responds to GET #search with bad encoding' do
VCR.use_cassette('gi_client/gets_institution_search_results') do
get '/v0/gi/institutions/search?name=%ADillinois'
end
expect(response).to be_successful
end
it 'responds to GET #show' do
VCR.use_cassette('gi_client/gets_the_institution_details') do
get '/v0/gi/institutions/11902614'
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_response_schema('gi/institution')
end
it 'responds to GET #show when camel-inflected' do
VCR.use_cassette('gi_client/gets_the_institution_details') do
get '/v0/gi/institutions/11902614', headers: inflection_header
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_camelized_response_schema('gi/institution')
end
it 'responds to GET #autocomplete' do
VCR.use_cassette('gi_client/gets_a_list_of_institution_autocomplete_suggestions') do
get '/v0/gi/institutions/autocomplete?term=university'
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_response_schema('gi/autocomplete')
end
it 'responds to GET #autocomplete when camel-inflected' do
VCR.use_cassette('gi_client/gets_a_list_of_institution_autocomplete_suggestions') do
get '/v0/gi/institutions/autocomplete?term=university', headers: inflection_header
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_camelized_response_schema('gi/autocomplete')
end
it 'responds to GET #autocomplete with bad encoding' do
VCR.use_cassette('gi_client/gets_a_list_of_institution_autocomplete_suggestions') do
get '/v0/gi/institutions/autocomplete?term=%ADuniversity'
end
expect(response).to be_successful
end
it 'responds to GET institution #children' do
VCR.use_cassette('gi_client/gets_the_institution_children') do
get '/v0/gi/institutions/10086018/children'
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_response_schema('gi/institution_children')
end
it 'responds to GET institution #children when camel-inflected' do
VCR.use_cassette('gi_client/gets_the_institution_children') do
get '/v0/gi/institutions/10086018/children', headers: inflection_header
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_camelized_response_schema('gi/institution_children')
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/preneeds/burial_forms_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::Preneeds::BurialForm', type: :request do
include SchemaMatchers
let(:params) do
{ application: attributes_for(:burial_form) }
end
# /v0/preneeds/burial_forms specs already removed in https://github.com/department-of-veterans-affairs/vets-api/pull/18232
describe '#send_confirmation_email' do
subject { V0::Preneeds::BurialFormsController.new }
let(:submission_record) { OpenStruct.new(application_uuid: 'UUID') }
let(:form) do
Preneeds::BurialForm.new(params[:application]).tap do |f|
f.claimant = Preneeds::Claimant.new(
email: 'foo@foo.com',
name: Preneeds::FullName.new(
first: 'Derrick',
last: 'Last'
)
)
f.applicant = Preneeds::Applicant.new(
applicant_relationship_to_claimant: 'Self',
applicant_email: 'bar@bar.com',
name: Preneeds::FullName.new(
first: 'Applicant',
last: 'Last'
)
)
end
end
it 'calls the send email job with the correct parameters' do
expect(VANotify::EmailJob).to receive(:perform_async).with(
'foo@foo.com',
'preneeds_burial_form_email_template_id',
{
'form_name' => 'Burial Pre-Need (Form 40-10007)',
'applicant_1_first_name_last_initial' => 'Applicant L',
'confirmation_number' => 'UUID',
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'first_name' => 'APPLICANT'
}
)
subject.instance_variable_set(:@form, form)
subject.instance_variable_set(:@resource, submission_record)
subject.send_confirmation_email
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/preneeds/cemeteries_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::Preneeds::Cemeteries', type: :request do
include SchemaMatchers
it 'responds to GET #index' do
VCR.use_cassette('preneeds/cemeteries/gets_a_list_of_cemeteries') do
get '/v0/preneeds/cemeteries/'
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_response_schema('preneeds/cemeteries')
end
it 'responds to GET #index when camel-inflected' do
VCR.use_cassette('preneeds/cemeteries/gets_a_list_of_cemeteries') do
get '/v0/preneeds/cemeteries/', headers: { 'X-Key-Inflection' => 'camel' }
end
expect(response).to be_successful
expect(response.body).to be_a(String)
expect(response).to match_camelized_response_schema('preneeds/cemeteries')
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/disability_compensation_form/rating_info_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::DisabilityCompensationForm::RatingInfo' do
include SchemaMatchers
let(:user) { build(:disabilities_compensation_user) }
before do
sign_in_as(user)
Flipper.disable('profile_lighthouse_rating_info')
end
describe 'GET /v0/disability_compensation_form/rating_info' do
context 'with a valid 200 evss response' do
it 'matches the rating info schema' do
VCR.use_cassette('evss/disability_compensation_form/rating_info') do
get '/v0/disability_compensation_form/rating_info'
expect(response).to have_http_status(:ok)
end
end
end
context 'with a 403 unauthorized response' do
let(:user) { build(:unauthorized_evss_user, :loa3) }
it 'returns a forbidden response' do
VCR.use_cassette('evss/disability_compensation_form/rating_info_403') do
get '/v0/disability_compensation_form/rating_info'
expect(response).to have_http_status(:forbidden)
expect(response).to match_response_schema('evss_errors', strict: false)
end
end
it 'returns a forbidden response when camel-inflected' do
VCR.use_cassette('evss/disability_compensation_form/rating_info_403') do
get '/v0/disability_compensation_form/rating_info', headers: { 'X-Key-Inflection' => 'camel' }
expect(response).to have_http_status(:forbidden)
expect(response).to match_camelized_response_schema('evss_errors', strict: false)
end
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/evss_claims/documents_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::EVSSClaimsDocuments', type: :request do
let(:file) { fixture_file_upload('doctors-note.pdf', 'application/pdf') }
let(:tracked_item_id) { 33 }
let(:document_type) { 'L023' }
let!(:claim) do
create(:evss_claim, id: 1, evss_id: 189_625,
user_uuid: user.uuid, data: {})
end
let(:user) { create(:user, :loa3) }
let(:user_account) { create(:user_account) }
before do
sign_in_as(user)
user.user_account_uuid = user_account.id
user.save!
end
context 'when cst_send_evidence_submission_failure_emails is disabled' do
before do
allow(Flipper).to receive(:enabled?).with(:cst_send_evidence_submission_failure_emails).and_return(false)
end
it 'uploads a file' do
params = { file:, tracked_item_id:, document_type: }
expect do
post('/v0/evss_claims/189625/documents', params:)
end.to change(EVSS::DocumentUpload.jobs, :size).by(1)
expect(response).to have_http_status(:accepted)
expect(JSON.parse(response.body)['job_id'])
.to eq(EVSS::DocumentUpload.jobs.first['jid'])
expect(EvidenceSubmission.count).to eq(0)
end
it 'rejects files with invalid document_types' do
params = { file:, tracked_item_id:, document_type: 'invalid type' }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title']).to eq(
I18n.t('errors.messages.uploads.document_type_unknown')
)
end
it 'normalizes requests with a null tracked_item_id' do
params = { file:, tracked_item_id: 'null', document_type: }
post('/v0/evss_claims/189625/documents', params:)
args = EVSS::DocumentUpload.jobs.first['args'][2]
expect(response).to have_http_status(:accepted)
expect(JSON.parse(response.body)['job_id'])
.to eq(EVSS::DocumentUpload.jobs.first['jid'])
expect(args.key?('tracked_item_id')).to be(true)
expect(args['tracked_item_id']).to be_nil
expect(EvidenceSubmission.count).to eq(0)
end
context 'when content type and file extension don’t match' do
let(:file) { fixture_file_upload('html.txt', 'text/plain') }
it 'rejects files when the content type and extension don’t match' do
params = { file:, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title']).to eq(
I18n.t('errors.messages.uploads.content_type_mismatch')
)
end
end
context 'with unaccepted file_type' do
let(:file) { fixture_file_upload('invalid_idme_cert.crt', 'application/x-x509-ca-cert') }
it 'rejects files with invalid document_types' do
params = { file:, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title']).to eq('Unprocessable Entity')
end
end
context 'with locked PDF and no provided password' do
let(:locked_file) { fixture_file_upload('locked_pdf_password_is_test.pdf', 'application/pdf') }
it 'rejects locked PDFs if no password is provided' do
params = { file: locked_file, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title']).to eq(I18n.t('errors.messages.uploads.pdf.locked'))
end
it 'accepts locked PDFs with the correct password' do
params = { file: locked_file, tracked_item_id:, document_type:, password: 'test' }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:accepted)
expect(JSON.parse(response.body)['job_id']).to eq(EVSS::DocumentUpload.jobs.first['jid'])
end
it 'rejects locked PDFs with the incorrect password' do
params = { file: locked_file, tracked_item_id:, document_type:, password: 'bad' }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title']).to eq(
I18n.t('errors.messages.uploads.pdf.incorrect_password')
)
end
end
context 'with a false file extension' do
let(:tempfile) do
f = Tempfile.new(['not-a', '.pdf'])
f.write('I am not a PDF')
f.rewind
fixture_file_upload(f.path, 'application/pdf')
end
it 'rejects a file that is not really a PDF' do
params = { file: tempfile, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title'])
.to eq(I18n.t('errors.messages.uploads.malformed_pdf'))
end
end
context 'with no body' do
let(:file) { fixture_file_upload('empty_file.txt', 'text/plain') }
it 'rejects a text file with no body' do
params = { file:, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['detail']).to eq(
I18n.t('errors.messages.min_size_error', min_size: '1 Byte')
)
end
end
context 'with an emoji in text' do
let(:tempfile) do
f = Tempfile.new(['test', '.txt'])
f.write("I \u2661 Unicode!")
f.rewind
fixture_file_upload(f.path, 'text/plain')
end
it 'rejects a text file containing untranslatable characters' do
params = { file: tempfile, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title'])
.to eq(I18n.t('errors.messages.uploads.ascii_encoded'))
end
end
context 'with UTF-16 ASCII text' do
let(:tempfile) do
f = Tempfile.new(['test', '.txt'], encoding: 'utf-16be')
f.write('I love nulls')
f.rewind
fixture_file_upload(f.path, 'text/plain')
end
it 'accepts a text file containing translatable characters' do
params = { file: tempfile, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:accepted)
expect(JSON.parse(response.body)['job_id']).to eq(EVSS::DocumentUpload.jobs.first['jid'])
expect(EvidenceSubmission.count).to eq(0)
end
end
context 'with a PDF pretending to be text' do
let(:tempfile) do
f = Tempfile.new(['test', '.txt'], encoding: 'utf-16be')
pdf = File.open(Rails.root.join(*'/spec/fixtures/files/doctors-note.pdf'.split('/')).to_s, 'rb')
FileUtils.copy_stream(pdf, f)
pdf.close
f.rewind
fixture_file_upload(f.path, 'text/plain')
end
it 'rejects a text file containing binary data' do
params = { file: tempfile, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title'])
.to eq(I18n.t('errors.messages.uploads.ascii_encoded'))
end
end
end
context 'when cst_send_evidence_submission_failure_emails is enabled' do
before do
allow(Flipper).to receive(:enabled?).with(:cst_send_evidence_submission_failure_emails).and_return(true)
end
it 'uploads a file' do
params = { file:, tracked_item_id:, document_type: }
expect do
post('/v0/evss_claims/189625/documents', params:)
end.to change(EVSS::DocumentUpload.jobs, :size).by(1)
expect(response).to have_http_status(:accepted)
expect(JSON.parse(response.body)['job_id']).to eq(EVSS::DocumentUpload.jobs.first['jid'])
expect(EvidenceSubmission.count).to eq(1)
end
it 'rejects files with invalid document_types' do
params = { file:, tracked_item_id:, document_type: 'invalid type' }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title']).to eq(
I18n.t('errors.messages.uploads.document_type_unknown')
)
expect(EvidenceSubmission.count).to eq(0)
end
it 'normalizes requests with a null tracked_item_id' do
params = { file:, tracked_item_id: 'null', document_type: }
post('/v0/evss_claims/189625/documents', params:)
args = EVSS::DocumentUpload.jobs.first['args'][2]
expect(response).to have_http_status(:accepted)
expect(JSON.parse(response.body)['job_id'])
.to eq(EVSS::DocumentUpload.jobs.first['jid'])
expect(args.key?('tracked_item_id')).to be(true)
expect(args['tracked_item_id']).to be_nil
expect(EvidenceSubmission.count).to eq(1)
end
context 'when content type and file extension don’t match' do
let(:file) { fixture_file_upload('html.txt', 'text/plain') }
it 'rejects files when the content type and extension don’t match' do
params = { file:, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title']).to eq(
I18n.t('errors.messages.uploads.content_type_mismatch')
)
expect(EvidenceSubmission.count).to eq(0)
end
end
context 'with unaccepted file_type' do
let(:file) { fixture_file_upload('invalid_idme_cert.crt', 'application/x-x509-ca-cert') }
it 'rejects files with invalid document_types' do
params = { file:, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title'])
.to eq('Unprocessable Entity')
expect(EvidenceSubmission.count).to eq(0)
end
end
context 'with locked PDF and no provided password' do
let(:locked_file) { fixture_file_upload('locked_pdf_password_is_test.pdf', 'application/pdf') }
it 'rejects locked PDFs if no password is provided' do
params = { file: locked_file, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title'])
.to eq(I18n.t('errors.messages.uploads.pdf.locked'))
expect(EvidenceSubmission.count).to eq(0)
end
it 'accepts locked PDFs with the correct password' do
params = { file: locked_file, tracked_item_id:, document_type:, password: 'test' }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:accepted)
expect(JSON.parse(response.body)['job_id'])
.to eq(EVSS::DocumentUpload.jobs.first['jid'])
expect(EvidenceSubmission.count).to eq(1)
end
it 'rejects locked PDFs with the incorrect password' do
params = { file: locked_file, tracked_item_id:, document_type:, password: 'bad' }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title']).to eq(
I18n.t('errors.messages.uploads.pdf.incorrect_password')
)
expect(EvidenceSubmission.count).to eq(0)
end
end
context 'with a false file extension' do
let(:tempfile) do
f = Tempfile.new(['not-a', '.pdf'])
f.write('I am not a PDF')
f.rewind
fixture_file_upload(f.path, 'application/pdf')
end
it 'rejects a file that is not really a PDF' do
params = { file: tempfile, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title'])
.to eq(I18n.t('errors.messages.uploads.malformed_pdf'))
expect(EvidenceSubmission.count).to eq(0)
end
end
context 'with no body' do
let(:file) { fixture_file_upload('empty_file.txt', 'text/plain') }
it 'rejects a text file with no body' do
params = { file:, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['detail']).to eq(
I18n.t('errors.messages.min_size_error', min_size: '1 Byte')
)
expect(EvidenceSubmission.count).to eq(0)
end
end
context 'with an emoji in text' do
let(:tempfile) do
f = Tempfile.new(['test', '.txt'])
f.write("I \u2661 Unicode!")
f.rewind
fixture_file_upload(f.path, 'text/plain')
end
it 'rejects a text file containing untranslatable characters' do
params = { file: tempfile, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title'])
.to eq(I18n.t('errors.messages.uploads.ascii_encoded'))
expect(EvidenceSubmission.count).to eq(0)
end
end
context 'with UTF-16 ASCII text' do
let(:tempfile) do
f = Tempfile.new(['test', '.txt'], encoding: 'utf-16be')
f.write('I love nulls')
f.rewind
fixture_file_upload(f.path, 'text/plain')
end
it 'accepts a text file containing translatable characters' do
params = { file: tempfile, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:accepted)
expect(JSON.parse(response.body)['job_id'])
.to eq(EVSS::DocumentUpload.jobs.first['jid'])
expect(EvidenceSubmission.count).to eq(1)
end
end
context 'with a PDF pretending to be text' do
let(:tempfile) do
f = Tempfile.new(['test', '.txt'], encoding: 'utf-16be')
pdf = File.open(Rails.root.join(*'/spec/fixtures/files/doctors-note.pdf'.split('/')).to_s, 'rb')
FileUtils.copy_stream(pdf, f)
pdf.close
f.rewind
fixture_file_upload(f.path, 'text/plain')
end
it 'rejects a text file containing binary data' do
params = { file: tempfile, tracked_item_id:, document_type: }
post('/v0/evss_claims/189625/documents', params:)
expect(response).to have_http_status(:unprocessable_entity)
expect(JSON.parse(response.body)['errors'].first['title'])
.to eq(I18n.t('errors.messages.uploads.ascii_encoded'))
expect(EvidenceSubmission.count).to eq(0)
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/full_name_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::Profile::FullName', type: :request do
include SchemaMatchers
before do
sign_in_as(build(:user, :loa3, middle_name: 'Robert'))
end
describe 'GET /v0/profile/full_name' do
context 'with a 200 response' do
it 'matches the full name schema' do
get '/v0/profile/full_name'
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('full_name_response')
end
it 'matches the full name schema when camel-inflected' do
get '/v0/profile/full_name', headers: { 'X-Key-Inflection' => 'camel' }
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('full_name_response')
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/personal_information_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'support/error_details'
RSpec.describe 'V0::Profile::PersonalInformation', feature: :personal_info,
team_owner: :vfs_authenticated_experience_backend,
type: :request do
include SchemaMatchers
include ErrorDetails
let(:user) { create(:user, :loa3, idme_uuid: 'b2fab2b5-6af0-45e1-a9e2-394347af91ef') }
before { sign_in(user) }
describe 'GET /v0/profile/personal_information' do
context 'with a 200 response' do
it 'matches the personal information schema' do
VCR.use_cassette('mpi/find_candidate/valid') do
VCR.use_cassette('va_profile/demographics/demographics') do
get '/v0/profile/personal_information'
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('personal_information_response')
end
end
end
end
context 'when MVI does not return a gender nor birthday', :skip_mvi do
let(:mpi_profile) { build(:mpi_profile, { birth_date: nil, gender: nil }) }
let(:user) { create(:user, :loa3, mpi_profile:, idme_uuid: 'b2fab2b5-6af0-45e1-a9e2-394347af91ef') }
it 'matches the errors schema', :aggregate_failures do
VCR.use_cassette('mpi/find_candidate/missing_birthday_and_gender') do
VCR.use_cassette('va_profile/demographics/demographics') do
get '/v0/profile/personal_information'
expect(response).to have_http_status(:bad_gateway)
expect(response).to match_response_schema('errors')
end
end
end
it 'includes the correct error code' do
VCR.use_cassette('mpi/find_candidate/missing_birthday_and_gender') do
VCR.use_cassette('va_profile/demographics/demographics') do
get '/v0/profile/personal_information'
expect(error_details_for(response, key: 'code')).to eq 'MVI_BD502'
end
end
end
end
context 'when VAProfile does not return a preferred name nor gender identity' do
it 'matches the errors schema', :aggregate_failures do
VCR.use_cassette('mpi/find_candidate/valid') do
VCR.use_cassette('va_profile/demographics/demographics_error_503') do
get '/v0/profile/personal_information'
expect(response).to have_http_status(:bad_gateway)
expect(response).to match_response_schema('errors')
end
end
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/service_history_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'support/error_details'
RSpec.describe 'V0::Profile::ServiceHistory', type: :request do
include SchemaMatchers
include ErrorDetails
let(:inflection_header) { { 'X-Key-Inflection' => 'camel' } }
describe 'GET /v0/profile/service_history' do
let(:user) { build(:user, :loa3) }
before do
sign_in(user)
end
# The following provides a description of the different termination reason codes:
# • "S" Separation From Personnel Category
# • "C" Completion of Active Service Period
# • "D" Death while in personnel category or organization
# • "W" Not Applicable
context 'when successful' do
it 'matches the service history schema' do
VCR.use_cassette('va_profile/military_personnel/post_read_service_history_200') do
get '/v0/profile/service_history'
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('service_history_response')
end
end
it 'matches the service history schema when camel-inflected' do
VCR.use_cassette('va_profile/military_personnel/post_read_service_history_200') do
get '/v0/profile/service_history', headers: inflection_header
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('service_history_response')
end
end
it 'returns a single service history episode and vet_status_eligibility' do
VCR.use_cassette('va_profile/military_personnel/post_read_service_history_200') do
get '/v0/profile/service_history'
json = json_body_for(response)
episode = json.dig('attributes', 'service_history').first
expect(episode['branch_of_service']).to eq('Army')
expect(episode['begin_date']).to eq('2002-02-02')
expect(episode['end_date']).to eq('2008-12-01')
expect(episode['period_of_service_type_code']).to eq('N')
expect(episode['period_of_service_type_text']).to eq('National Guard member')
expect(episode['termination_reason_code']).to eq('S')
expect(episode['termination_reason_text']).to eq('Separation from personnel category or organization')
expect(json.dig('attributes', 'vet_status_eligibility')).to eq(
{ 'confirmed' => true, 'message' => [], 'title' => '', 'status' => '' }
)
end
end
it 'returns no service history episodes' do
VCR.use_cassette('va_profile/military_personnel/post_read_service_history_200_empty') do
get '/v0/profile/service_history'
json = json_body_for(response)
episodes = json.dig('attributes', 'service_history')
vet_status_eligibility = json.dig('attributes', 'vet_status_eligibility')
expect(response).to be_ok
expect(episodes.count).to eq(0)
expect(vet_status_eligibility).to eq({ 'confirmed' => false,
'message' => VeteranVerification::Constants::NOT_FOUND_MESSAGE,
'title' => VeteranVerification::Constants::NOT_FOUND_MESSAGE_TITLE,
'status' => VeteranVerification::Constants::NOT_FOUND_MESSAGE_STATUS })
end
end
context 'when academy attendance flag is off' do
before do
Flipper.disable(:profile_show_military_academy_attendance)
end
it 'returns military service episodes only' do
VCR.use_cassette('va_profile/military_personnel/post_read_service_histories_200') do
get '/v0/profile/service_history'
json = json_body_for(response)
episodes = json.dig('attributes', 'service_history')
expect(episodes.count).to eq(3)
episodes.each do |e|
expect(e['service_type']).to eq(VAProfile::Models::ServiceHistory::MILITARY_SERVICE)
expect(e['branch_of_service']).not_to be_nil
expect(e['begin_date']).not_to be_nil
expect(e['end_date']).not_to be_nil
expect(e['period_of_service_type_code']).not_to be_nil
expect(e['period_of_service_type_text']).not_to be_nil
expect(e['termination_reason_code']).not_to be_nil
expect(e['termination_reason_text']).not_to be_nil
end
end
end
end
context 'when academy attendance flag is on' do
before do
Flipper.enable(:profile_show_military_academy_attendance)
end
it 'returns military service and academy attendance episodes' do
VCR.use_cassette('va_profile/military_personnel/post_read_service_histories_200') do
get '/v0/profile/service_history'
json = json_body_for(response)
episodes = json.dig('attributes', 'service_history')
expect(episodes.count).to eq(5)
episodes.each do |e|
expect(e['branch_of_service']).not_to be_nil
expect(e['begin_date']).not_to be_nil
expect(e['end_date']).not_to be_nil
unless e['service_type'] == VAProfile::Models::ServiceHistory::MILITARY_SERVICE
expect(e['service_type']).to eq(VAProfile::Models::ServiceHistory::ACADEMY_ATTENDANCE)
end
end
end
end
end
end
context 'when not successful' do
context 'when external service returns 400 response' do
it 'returns 400 with nil service history' do
VCR.use_cassette('va_profile/military_personnel/post_read_service_history_400') do
get '/v0/profile/service_history'
expect(response).to have_http_status(:bad_request)
end
end
end
context 'when external service returns 500 response' do
it 'returns 400 with nil service history' do
VCR.use_cassette('va_profile/military_personnel/post_read_service_history_500') do
get '/v0/profile/service_history'
expect(response).to have_http_status(:bad_request)
end
end
end
end
describe 'eligible benefits logging' do
context 'with log_eligible_benefits feature flag on' do
before { allow(Flipper).to receive(:enabled?).with(:log_eligible_benefits).and_return(true) }
context 'when service history response succeeds' do
it 'logs eligible benefits' do
expect(Lighthouse::BenefitsDiscovery::LogEligibleBenefitsJob).to receive(:perform_async).with(
user.uuid,
[{
startDate: '2002-02-02',
endDate: '2008-12-01',
dischargeStatus: 'GENERAL_DISCHARGE',
branchOfService: 'ARMY'
}]
)
VCR.use_cassette('va_profile/military_personnel/post_read_service_history_200') do
get '/v0/profile/service_history'
end
expect(response).to have_http_status(:ok)
end
end
context 'when service history response fails' do
it 'does not log eligible benefits' do
expect(Lighthouse::BenefitsDiscovery::LogEligibleBenefitsJob).not_to receive(:perform_async)
VCR.use_cassette('va_profile/military_personnel/post_read_service_history_500') do
get '/v0/profile/service_history'
end
expect(response).to have_http_status(:bad_request)
end
end
context 'when params creation fails' do
it 'logs error, does not log benefits, and does not cause request error' do
allow(BenefitsDiscovery::Params).to receive(:service_history_params).and_raise(StandardError.new('oops'))
expect(Rails.logger).to receive(:error).with('Error logging eligible benefits: oops')
expect(Lighthouse::BenefitsDiscovery::LogEligibleBenefitsJob).not_to receive(:perform_async)
VCR.use_cassette('va_profile/military_personnel/post_read_service_history_200') do
get '/v0/profile/service_history'
end
expect(response).to have_http_status(:ok)
end
end
end
context 'with log_eligible_benefits feature flag off' do
before { allow(Flipper).to receive(:enabled?).with(:log_eligible_benefits).and_return(false) }
it 'does not log eligible benefits' do
expect(Lighthouse::BenefitsDiscovery::LogEligibleBenefitsJob).not_to receive(:perform_async)
VCR.use_cassette('va_profile/military_personnel/post_read_service_history_200') do
get '/v0/profile/service_history'
end
expect(response).to have_http_status(:ok)
end
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/email_addresses_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::Profile::EmailAddresses', type: :request do
include SchemaMatchers
let(:user) { build(:user, :loa3, :legacy_icn) }
let(:headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } }
let(:headers_with_camel) { headers.merge('X-Key-Inflection' => 'camel') }
let(:contact_info) { VAProfileRedis::V2::ContactInformation.for_user(user) }
before do
allow(VAProfile::Configuration::SETTINGS.contact_information).to receive(:cache_enabled).and_return(true)
user.vet360_contact_info
sign_in_as(user)
end
describe 'POST /v0/profile/email_addresses/create_or_update' do
let(:email) { build(:email) }
it 'calls update_email' do
expect_any_instance_of(VAProfile::ContactInformation::V2::Service).to receive(:update_email).and_call_original
VCR.use_cassette('va_profile/v2/contact_information/put_email_success') do
post('/v0/profile/email_addresses/create_or_update', params: email.to_json, headers:)
end
expect(response).to have_http_status(:ok)
end
end
describe 'POST /v0/profile/email_addresses' do
let(:email) { build(:email) }
context 'with a 200 response' do
it 'matches the email address schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_email_success') do
post('/v0/profile/email_addresses', params: { email_address: 'test@example.com' }.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'matches the email address camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_email_success') do
post('/v0/profile/email_addresses',
params: { email_address: 'test@example.com' }.to_json,
headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
it 'creates a new AsyncTransaction::VAProfile::EmailTransaction db record' do
VCR.use_cassette('va_profile/v2/contact_information/post_email_success') do
expect do
post('/v0/profile/email_addresses', params: { email_address: 'test@example.com' }.to_json, headers:)
end.to change(AsyncTransaction::VAProfile::EmailTransaction, :count).from(0).to(1)
end
end
it 'invalidates the cache for the va-profile-v2-contact-info-response Redis key' do
VCR.use_cassette('va_profile/v2/contact_information/post_email_success') do
expect_any_instance_of(Common::RedisStore).to receive(:destroy)
post('/v0/profile/email_addresses', params: { email_address: 'test@example.com' }.to_json, headers:)
end
end
end
context 'with a 400 response id error' do
it 'matches the errors schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_email_w_id_error') do
post('/v0/profile/email_addresses',
params: { id: 42, email_address: 'person42@example.com' }.to_json, headers:)
expect(response).to have_http_status(:bad_request)
expect(response).to match_response_schema('errors')
end
end
it 'matches the errors camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_email_w_id_error') do
post('/v0/profile/email_addresses',
params: { id: 42, email_address: 'person42@example.com' }.to_json,
headers: headers_with_camel)
expect(response).to have_http_status(:bad_request)
expect(response).to match_camelized_response_schema('errors')
end
end
it 'does not invalidate the cache' do
VCR.use_cassette('va_profile/v2/contact_information/post_email_w_id_error') do
expect_any_instance_of(Common::RedisStore).not_to receive(:destroy)
post('/v0/profile/email_addresses',
params: { id: 42, email_address: 'person42@example.com' }.to_json, headers:)
end
end
end
context 'with a 400 response' do
it 'returns a forbidden response' do
VCR.use_cassette('va_profile/v2/contact_information/post_email_status_400') do
post('/v0/profile/email_addresses', params: { email_address: 'test@example.com' }.to_json, headers:)
expect(response).to have_http_status(:bad_request)
end
end
end
context 'with a validation issue' do
it 'matches the errors schema', :aggregate_failures do
post('/v0/profile/email_addresses', params: { email_address: '' }.to_json, headers:)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_response_schema('errors')
expect(errors_for(response)).to include "email-address - can't be blank"
end
it 'matches the errors camel-inflected schema', :aggregate_failures do
post('/v0/profile/email_addresses', params: { email_address: '' }.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_camelized_response_schema('errors')
expect(errors_for(response)).to include "email-address - can't be blank"
end
end
end
describe 'PUT /v0/profile/email_addresses' do
let(:email) { build(:email) }
context 'with a 200 response' do
it 'matches the email address schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/put_email_success') do
put('/v0/profile/email_addresses',
params: { id: 42, email_address: 'person42@example.com' }.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'matches the email address camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/put_email_success') do
put('/v0/profile/email_addresses',
params: { id: 42, email_address: 'person42@example.com' }.to_json,
headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
it 'creates a new AsyncTransaction::VAProfile::EmailTransaction db record' do
VCR.use_cassette('va_profile/v2/contact_information/put_email_success') do
expect do
put('/v0/profile/email_addresses',
params: { id: 42, email_address: 'person42@example.com' }.to_json, headers:)
end.to change(AsyncTransaction::VAProfile::EmailTransaction, :count).from(0).to(1)
end
end
it 'invalidates the cache for the va-profile-v2-contact-info-response Redis key' do
VCR.use_cassette('va_profile/v2/contact_information/put_email_success') do
expect_any_instance_of(Common::RedisStore).to receive(:destroy)
put('/v0/profile/email_addresses',
params: { id: 42, email_address: 'person42@example.com' }.to_json, headers:)
end
end
end
context 'with a validation issue' do
it 'matches the errors schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/person') do
put('/v0/profile/email_addresses', params: { email_address: '' }.to_json, headers:)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_response_schema('errors')
expect(errors_for(response)).to include "email-address - can't be blank"
end
end
it 'matches the errors camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/person') do
put('/v0/profile/email_addresses', params: { email_address: '' }.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_camelized_response_schema('errors')
expect(errors_for(response)).to include "email-address - can't be blank"
end
end
end
context 'when effective_end_date is included' do
let(:email) do
build(:email,
email_address: 'person42@example.com',
effective_end_date: '2024-09-09T11:52:03.000-06:00')
end
let(:id_in_cassette) { 42 }
before do
allow_any_instance_of(User).to receive(:icn).and_return('1234')
email.id = id_in_cassette
end
end
end
describe 'DELETE /v0/profile/email_addresses' do
let(:email) do
build(:email, email_address: 'person42@example.com')
end
before do
Timecop.freeze(Time.zone.local(2018, 6, 6, 15, 35, 55))
end
after do
Timecop.return
end
context 'when the method is DELETE' do
it 'effective_end_date gets appended to the request body', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/delete_email_success', VCR::MATCH_EVERYTHING) do
delete('/v0/profile/email_addresses', params: email.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'effective_end_date gets appended to the request body when camel-inflected', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/delete_email_success', VCR::MATCH_EVERYTHING) do
delete('/v0/profile/email_addresses', params: email.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/persons_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::Profile::Persons', type: :request do
include SchemaMatchers
let(:user) { build(:user, :loa3) }
let(:headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } }
let(:headers_with_camel) { headers.merge('X-Key-Inflection' => 'camel') }
before do
Timecop.freeze('2024-09-16T16:09:37Z')
sign_in_as(user)
end
after do
Timecop.return
end
describe 'POST /v0/profile/initialize_vet360_id' do
let(:empty_body) do
{
bio: {
sourceDate: Time.zone.now.iso8601
}
}.to_json
end
context 'with a user that has an icn' do
it 'matches the transaction response schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/person/init_vet360_id_success', VCR::MATCH_EVERYTHING) do
post('/v0/profile/initialize_vet360_id', params: empty_body, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'matches the transaction response camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/person/init_vet360_id_success', VCR::MATCH_EVERYTHING) do
post('/v0/profile/initialize_vet360_id', params: empty_body, headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
it 'creates a new AsyncTransaction::VAProfile::InitializePersonTransaction', :aggregate_failures do
VCR.use_cassette('va_profile/v2/person/init_vet360_id_success', VCR::MATCH_EVERYTHING) do
expect do
post('/v0/profile/initialize_vet360_id', params: empty_body, headers:)
end.to change(AsyncTransaction::VAProfile::InitializePersonTransaction, :count).from(0).to(1)
expect(AsyncTransaction::VAProfile::InitializePersonTransaction.first).to be_valid
end
end
it 'invalidates the cache for the mpi-profile-response Redis key' do
VCR.use_cassette('va_profile/v2/person/init_vet360_id_success', VCR::MATCH_EVERYTHING) do
expect_any_instance_of(User).to receive(:invalidate_mpi_cache)
post('/v0/profile/initialize_vet360_id', params: empty_body, headers:)
end
end
end
context 'with an error response' do
it 'matches the errors response schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/person/init_vet360_id_status_400', VCR::MATCH_EVERYTHING) do
post('/v0/profile/initialize_vet360_id', params: empty_body, headers:)
expect(response).to have_http_status(:bad_request)
expect(response).to match_response_schema('errors')
end
end
it 'matches the errors response camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/person/init_vet360_id_status_400', VCR::MATCH_EVERYTHING) do
post('/v0/profile/initialize_vet360_id', params: empty_body, headers: headers_with_camel)
expect(response).to have_http_status(:bad_request)
expect(response).to match_camelized_response_schema('errors')
end
end
end
end
describe 'GET /v0/profile/person/status/:transaction_id' do
context 'with an ok response' do
let(:transaction) do
create(:initialize_person_transaction,
:init_vet360_id,
user_uuid: user.uuid,
transaction_id: '153536a5-8b18-4572-a3d9-4030bea3ab5c')
end
it 'responds with a serialized transaction', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/person_transaction_status') do
get("/v0/profile/person/status/#{transaction.transaction_id}", params: nil, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'responds with a serialized transaction when camel-inflected', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/person_transaction_status') do
get("/v0/profile/person/status/#{transaction.transaction_id}", params: nil, headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
end
context 'with an error response' do
let(:transaction) do
create(:initialize_person_transaction,
:init_vet360_id,
user_uuid: user.uuid,
transaction_id: 'd47b3d96-9ddd-42be-ac57-8e564aa38029')
end
it 'matches the errors response schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/person_transaction_status_error',
VCR::MATCH_EVERYTHING) do
get("/v0/profile/person/status/#{transaction.transaction_id}", params: nil, headers:)
expect(response).to have_http_status(:bad_request)
expect(response).to match_response_schema('errors')
end
end
it 'matches the errors response camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/person_transaction_status_error',
VCR::MATCH_EVERYTHING) do
get("/v0/profile/person/status/#{transaction.transaction_id}", params: nil, headers: headers_with_camel)
expect(response).to have_http_status(:bad_request)
expect(response).to match_camelized_response_schema('errors')
end
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/gender_identities_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'va_profile/models/gender_identity'
RSpec.describe 'V0::Profile::GenderIdentities', feature: :personal_info,
team_owner: :vfs_authenticated_experience_backend,
type: :request do
include SchemaMatchers
let(:user) { build(:user, :loa3, :legacy_icn, idme_uuid: 'b2fab2b5-6af0-45e1-a9e2-394347af91ef') }
let(:headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } }
let(:time) { Time.zone.local(2022, 4, 8, 15, 9, 23) }
before do
Timecop.freeze(time)
sign_in_as(user)
end
after do
Timecop.return
end
describe 'PUT /v0/profile/gender_identities' do
context 'with a 200 response' do
it 'matches the gender_identity schema', :aggregate_failures do
gender_identity = VAProfile::Models::GenderIdentity.new(code: 'F')
VCR.use_cassette('va_profile/demographics/post_gender_identity_success') do
put('/v0/profile/gender_identities', params: gender_identity.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/gender_identity_response')
end
end
it 'returns the correct values', :aggregate_failures do
gender_identity = VAProfile::Models::GenderIdentity.new(code: 'F')
VCR.use_cassette('va_profile/demographics/post_gender_identity_success') do
put('/v0/profile/gender_identities', params: gender_identity.to_json, headers:)
json = json_body_for(response)['attributes']['gender_identity']
expect(response).to have_http_status(:ok)
expect(json['code']).to eq(gender_identity.code)
expect(json['name']).to eq(gender_identity.name)
expect(json['source_system_user']).to eq('123498767V234859')
expect(json['source_date']).to eq('2022-04-08T15:09:23.000Z')
end
end
end
context 'matches the errors schema' do
it 'when code is blank', :aggregate_failures do
gender_identity = VAProfile::Models::GenderIdentity.new(code: nil)
put('/v0/profile/gender_identities', params: gender_identity.to_json, headers:)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_response_schema('errors')
expect(errors_for(response)).to include "code - can't be blank"
end
it 'when code is an invalid option', :aggregate_failures do
gender_identity = VAProfile::Models::GenderIdentity.new(code: 'A')
put('/v0/profile/gender_identities', params: gender_identity.to_json, headers:)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_response_schema('errors')
expect(errors_for(response)).to include 'code - invalid code'
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/telephones_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::Profile::Telephones', type: :request do
include SchemaMatchers
let(:user) { build(:user, :loa3, :legacy_icn) }
let(:headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } }
let(:headers_with_camel) { headers.merge('X-Key-Inflection' => 'camel') }
let(:time) { Time.zone.local(2018, 6, 6, 15, 35, 55) }
before do
sign_in_as(user)
end
describe 'POST /v0/profile/telephones' do
let(:telephone) { build(:telephone, vet360_id: user.vet360_id) }
context 'with a 200 response' do
it 'matches the telephone schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_telephone_success') do
post('/v0/profile/telephones', params: telephone.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'matches the telephone camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_telephone_success') do
post('/v0/profile/telephones', params: telephone.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
it 'creates a new AsyncTransaction::VAProfile::TelephoneTransaction db record' do
VCR.use_cassette('va_profile/v2/contact_information/post_telephone_success') do
expect do
post('/v0/profile/telephones', params: telephone.to_json, headers:)
end.to change(AsyncTransaction::VAProfile::TelephoneTransaction, :count).from(0).to(1)
end
end
end
context 'with a 400 response' do
it 'matches the errors schema', :aggregate_failures do
telephone.id = 42
VCR.use_cassette('va_profile/v2/contact_information/post_telephone_w_id_error') do
post('/v0/profile/telephones', params: telephone.to_json, headers:)
expect(response).to have_http_status(:bad_request)
expect(response).to match_response_schema('errors')
end
end
it 'matches the errors camel-inflected schema', :aggregate_failures do
telephone.id = 42
VCR.use_cassette('va_profile/v2/contact_information/post_telephone_w_id_error') do
post('/v0/profile/telephones', params: telephone.to_json, headers:)
expect(response).to have_http_status(:bad_request)
expect(response).to match_camelized_response_schema('errors')
end
end
end
context 'with a 403 response' do
it 'returns a forbidden response' do
VCR.use_cassette('va_profile/v2/contact_information/post_telephone_status_403') do
post('/v0/profile/telephones', params: telephone.to_json, headers:)
expect(response).to have_http_status(:forbidden)
end
end
end
context 'with a validation issue' do
it 'matches the errors schema', :aggregate_failures do
telephone.phone_number = ''
post('/v0/profile/telephones', params: telephone.to_json, headers:)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_response_schema('errors')
expect(errors_for(response)).to include "phone-number - can't be blank"
end
it 'matches the errors camel-inflected schema', :aggregate_failures do
telephone.phone_number = ''
post('/v0/profile/telephones', params: telephone.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_camelized_response_schema('errors')
expect(errors_for(response)).to include "phone-number - can't be blank"
end
end
end
describe 'PUT /v0/profile/telephones' do
let(:telephone) { build(:telephone, id: 42) }
context 'with a 200 response' do
it 'matches the telephone schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/put_telephone_success') do
put('/v0/profile/telephones', params: telephone.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'matches the telephone camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/put_telephone_success') do
put('/v0/profile/telephones', params: telephone.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
it 'creates a new AsyncTransaction::VAProfile::TelephoneTransaction db record' do
VCR.use_cassette('va_profile/v2/contact_information/put_telephone_success') do
expect do
put('/v0/profile/telephones', params: telephone.to_json, headers:)
end.to change(AsyncTransaction::VAProfile::TelephoneTransaction, :count).from(0).to(1)
end
end
end
context 'with a validation issue' do
it 'matches the errors schema', :aggregate_failures do
telephone.phone_number = ''
put('/v0/profile/telephones', params: telephone.to_json, headers:)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_response_schema('errors')
expect(errors_for(response)).to include "phone-number - can't be blank"
end
it 'matches the errors camel-inflected schema', :aggregate_failures do
telephone.phone_number = ''
put('/v0/profile/telephones', params: telephone.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_camelized_response_schema('errors')
expect(errors_for(response)).to include "phone-number - can't be blank"
end
end
context 'when effective_end_date is included' do
let(:time) { Time.zone.parse('2020-01-17T04:21:59.000Z') }
let(:telephone) do
build(:telephone,
id: 17_259,
vet360_id: user.vet360_id,
effective_end_date: Time.now.utc.iso8601,
phone_number: '5551234')
end
before do
Timecop.freeze(time)
sign_in_as(user)
end
after do
Timecop.return
end
it 'effective_end_date is NOT included in the request body', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/put_telephone_ignore_eed', VCR::MATCH_EVERYTHING) do
# The cassette we're using does not include the effectiveEndDate in the body.
# So this test ensures that it was stripped out
put('/v0/profile/telephones', params: telephone.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'effective_end_date is NOT included in the request body when camel-inflected', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/put_telephone_ignore_eed', VCR::MATCH_EVERYTHING) do
# The cassette we're using does not include the effectiveEndDate in the body.
# So this test ensures that it was stripped out
put('/v0/profile/telephones', params: telephone.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
end
end
describe 'POST /v0/profile/telephones/create_or_update' do
before do
Timecop.freeze(Time.zone.parse('2024-08-27T18:51:06.000Z'))
end
after do
Timecop.return
end
let(:telephone) { build(:telephone, id: 42) }
it 'calls update_telephone' do
expect_any_instance_of(VAProfile::ContactInformation::V2::Service).to receive(:update_telephone)
.and_call_original
VCR.use_cassette('va_profile/v2/contact_information/put_telephone_success') do
post('/v0/profile/telephones/create_or_update', params: telephone.to_json, headers:)
end
expect(response).to have_http_status(:ok)
end
end
describe 'DELETE /v0/profile/telephones' do
before do
Timecop.freeze(Time.zone.parse('2024-08-27T18:51:06.000Z'))
end
after do
Timecop.return
end
let(:telephone) { build(:telephone, source_system_user: user.icn, id: 42) }
context 'when the method is DELETE' do
it 'effective_end_date gets appended to the request body', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/delete_telephone_success', VCR::MATCH_EVERYTHING) do
# The cassette we're using includes the effectiveEndDate in the body.
# So this test will not pass if it's missing
delete('/v0/profile/telephones', params: telephone.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'effective_end_date gets appended to the request body when camel-inflected', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/delete_telephone_success', VCR::MATCH_EVERYTHING) do
# The cassette we're using includes the effectiveEndDate in the body.
# So this test will not pass if it's missing
delete('/v0/profile/telephones', params: telephone.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
context 'with international phone number' do
# Override the date just for international tests
before do
Timecop.freeze(Time.zone.parse('2025-09-02T18:51:06.000Z'))
end
let(:international_telephone) do
build(:telephone,
source_system_user: user.icn,
vet360_id: user.vet360_id,
is_international: true,
country_code: '44',
area_code: nil,
phone_number: '2045675000',
id: 42)
end
it 'effective_end_date gets appended to the request body', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/delete_international_telephone_success',
VCR::MATCH_EVERYTHING) do
# The cassette we're using includes the effectiveEndDate in the body.
# So this test will not pass if it's missing
delete('/v0/profile/telephones', params: international_telephone.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'effective_end_date gets appended to the request body when camel-inflected', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/delete_international_telephone_success',
VCR::MATCH_EVERYTHING) do
# The cassette we're using includes the effectiveEndDate in the body.
# So this test will not pass if it's missing
delete('/v0/profile/telephones', params: international_telephone.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/preferred_names_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'va_profile/models/preferred_name'
RSpec.describe 'V0::Profile::PreferredNames', feature: :personal_info,
team_owner: :vfs_authenticated_experience_backend,
type: :request do
include SchemaMatchers
let(:user) { build(:user, :loa3, :legacy_icn, idme_uuid: 'b2fab2b5-6af0-45e1-a9e2-394347af91ef') }
let(:headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } }
let(:time) { Time.zone.local(2022, 4, 8, 15, 9, 23) }
before do
Timecop.freeze(time)
sign_in_as(user)
end
after do
Timecop.return
end
describe 'PUT /v0/profile/preferred_names' do
context 'with a 200 response' do
it 'matches the preferred_name schema', :aggregate_failures do
preferred_name = VAProfile::Models::PreferredName.new(text: 'Pat')
VCR.use_cassette('va_profile/demographics/post_preferred_name_success') do
put('/v0/profile/preferred_names', params: preferred_name.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/preferred_name_response')
end
end
it 'returns the correct values', :aggregate_failures do
preferred_name = VAProfile::Models::PreferredName.new(text: 'Pat')
VCR.use_cassette('va_profile/demographics/post_preferred_name_success') do
put('/v0/profile/preferred_names', params: preferred_name.to_json, headers:)
json = json_body_for(response)['attributes']['preferred_name']
expect(response).to have_http_status(:ok)
expect(json['text']).to eq(preferred_name.text)
expect(json['source_system_user']).to eq('123498767V234859')
expect(json['source_date']).to eq('2022-04-08T15:09:23.000Z')
end
end
it 'invalidates the cache for the mpi-profile-response' do
preferred_name = VAProfile::Models::PreferredName.new(text: 'Pat')
VCR.use_cassette('va_profile/demographics/post_preferred_name_success') do
expect_any_instance_of(User).to receive(:invalidate_mpi_cache)
put('/v0/profile/preferred_names', params: preferred_name.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/preferred_name_response')
end
end
end
context 'matches the errors schema' do
it 'when text is blank', :aggregate_failures do
preferred_name = VAProfile::Models::PreferredName.new(text: nil)
put('/v0/profile/preferred_names', params: preferred_name.to_json, headers:)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_response_schema('errors')
expect(errors_for(response)).to include "text - can't be blank"
end
it 'when text is too long', :aggregate_failures do
preferred_name = VAProfile::Models::PreferredName.new(text: 'A' * 26)
put('/v0/profile/preferred_names', params: preferred_name.to_json, headers:)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_response_schema('errors')
expect(errors_for(response)).to include 'text - is too long (maximum is 25 characters)'
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/contacts_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::Profile::Contacts', type: :request do
include SchemaMatchers
let(:user) { build(:user, :loa3, idme_uuid:) }
let(:resource) { JSON.parse(response.body) }
around do |ex|
VCR.use_cassette(cassette) { ex.run }
end
describe 'GET /v0/profile/contacts' do
context '200 response' do
let(:idme_uuid) { 'dd681e7d6dea41ad8b80f8d39284ef29' }
let(:cassette) { 'va_profile/profile/v3/health_benefit_bio_200' }
it 'responds with contacts' do
sign_in_as(user)
get '/v0/profile/contacts'
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('contacts')
expect(resource['data'].size).to eq(4)
end
end
context '401 response' do
let(:idme_uuid) { 'dd681e7d6dea41ad8b80f8d39284ef29' }
let(:cassette) { 'va_profile/profile/v3/health_benefit_bio_200' }
it 'responds with 401 status' do
get '/v0/profile/contacts'
expect(response).to have_http_status(:unauthorized)
end
end
context '403 response' do
let(:user) { build(:user, :loa1) }
let(:cassette) { 'va_profile/profile/v3/health_benefit_bio_200' }
it 'responds with 403 status' do
sign_in_as(user)
get '/v0/profile/contacts'
expect(response).to have_http_status(:forbidden)
end
end
context '404 response' do
let(:idme_uuid) { '88f572d4-91af-46ef-a393-cba6c351e252' }
let(:cassette) { 'va_profile/profile/v3/health_benefit_bio_404' }
it 'responds with 404 status' do
sign_in_as(user)
get '/v0/profile/contacts'
expect(response).to have_http_status(:not_found)
end
end
context '500 response from VA Profile' do
let(:idme_uuid) { '88f572d4-91af-46ef-a393-cba6c351e252' }
let(:cassette) { 'va_profile/profile/v3/health_benefit_bio_500' }
it 'responds with 400 status (excluding 5xx response from SLO)' do
sign_in_as(user)
get '/v0/profile/contacts'
expect(response).to have_http_status(:bad_request)
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/addresses_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::Profile::Addresses', type: :request do
include SchemaMatchers
let(:user) { build(:user, :loa3, :legacy_icn) }
let(:headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } }
let(:headers_with_camel) { headers.merge('X-Key-Inflection' => 'camel') }
let(:frozen_time) { Time.zone.local(2018, 6, 6, 15, 35, 55) }
before do
Timecop.freeze(frozen_time)
sign_in_as(user)
end
after do
Timecop.return
end
describe 'POST /v0/profile/addresses' do
let(:address) { build(:va_profile_address) }
context 'with a 200 response' do
it 'matches the address schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_address_success') do
post('/v0/profile/addresses', params: address.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'matches the address camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_address_success') do
post('/v0/profile/addresses', params: address.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
it 'creates a new AsyncTransaction::VAProfile::AddressTransaction db record' do
VCR.use_cassette('va_profile/v2/contact_information/post_address_success') do
expect do
post('/v0/profile/addresses', params: address.to_json, headers:)
end.to change(AsyncTransaction::VAProfile::AddressTransaction, :count).from(0).to(1)
end
end
end
end
describe 'POST /v0/profile/addresses 400' do
let(:address) { build(:va_profile_address, :id_error, vet360_id: user.vet360_id) }
let(:frozen_time) { Time.zone.parse('2024-08-27T18:51:06.012Z') }
context 'with a 400 response' do
it 'matches the errors schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_address_w_id_error') do
post('/v0/profile/addresses', params: address.to_json, headers:)
expect(response).to have_http_status(:bad_request)
expect(response).to match_response_schema('errors')
end
end
it 'matches the errors camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_address_w_id_error') do
post('/v0/profile/addresses', params: address.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:bad_request)
expect(response).to match_camelized_response_schema('errors')
end
end
end
context 'with a low confidence error' do
it 'returns the low confidence error error code', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_address_w_low_confidence_error') do
low_confidence_error = 'VET360_ADDR306'
post('/v0/profile/addresses', params: address.to_json, headers:)
body = JSON.parse response.body
expect(body['errors'].first['code']).to eq low_confidence_error
expect(response).to have_http_status(:bad_request)
expect(response).to match_response_schema('errors')
end
end
it 'returns the low confidence error error code when camel-inflected', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/post_address_w_low_confidence_error') do
low_confidence_error = 'VET360_ADDR306'
post('/v0/profile/addresses', params: address.to_json, headers: headers_with_camel)
body = JSON.parse response.body
expect(body['errors'].first['code']).to eq low_confidence_error
expect(response).to have_http_status(:bad_request)
expect(response).to match_camelized_response_schema('errors')
end
end
end
context 'with a 403 response' do
it 'returns a forbidden response' do
VCR.use_cassette('va_profile/v2/contact_information/post_address_status_403') do
post('/v0/profile/addresses', params: address.to_json, headers:)
expect(response).to have_http_status(:forbidden)
end
end
end
context 'with a validation issue' do
before do
address.address_pou = ''
end
it 'creates a PII log for the validation error' do
post('/v0/profile/addresses', params: address.to_json, headers:)
log = PersonalInformationLog.last
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::Address ValidationError')
end
it 'matches the errors schema', :aggregate_failures do
post('/v0/profile/addresses', params: address.to_json, headers:)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_response_schema('errors')
expect(errors_for(response)).to include "address-pou - can't be blank"
end
it 'matches the errors camel-inflected schema', :aggregate_failures do
post('/v0/profile/addresses', params: address.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_camelized_response_schema('errors')
expect(errors_for(response)).to include "address-pou - can't be blank"
end
end
end
describe 'PUT /v0/profile/addresses' do
let(:address) { build(:va_profile_address) }
context 'with a 200 response' do
it 'matches the email address schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/put_address_success') do
put('/v0/profile/addresses', params: address.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'matches the email address camel-inflected schema', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/put_address_success') do
put('/v0/profile/addresses', params: address.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
it 'creates a new AsyncTransaction::VAProfile::AddressTransaction db record' do
VCR.use_cassette('va_profile/v2/contact_information/put_address_success') do
expect do
put('/v0/profile/addresses', params: address.to_json, headers:)
end.to change(AsyncTransaction::VAProfile::AddressTransaction, :count).from(0).to(1)
end
end
context 'with a validation key' do
let(:address) do
build(:va_profile_address, :override, country_name: nil)
end
let(:frozen_time) { Time.zone.parse('2024-09-16T16:09:37.000Z') }
before do
allow_any_instance_of(User).to receive(:icn).and_return('123498767V234859')
allow(Settings).to receive(:virtual_hosts).and_return('www.example.com')
end
it 'is successful' do
VCR.use_cassette('va_profile/v2/contact_information/put_address_override', VCR::MATCH_EVERYTHING) do
address.id = 577_127
put('/v0/profile/addresses', params: address.to_json, headers:)
expect(JSON.parse(response.body)['data']['attributes']['transaction_id']).to eq(
'cd7036df-630c-43e2-8911-063daa10021c'
)
end
end
end
end
context 'with a validation issue' do
it 'matches the errors schema', :aggregate_failures do
address.address_pou = ''
put('/v0/profile/addresses', params: address.to_json, headers:)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_response_schema('errors')
expect(errors_for(response)).to include "address-pou - can't be blank"
end
it 'matches the errors camel-inflected schema', :aggregate_failures do
address.address_pou = ''
put('/v0/profile/addresses', params: address.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_camelized_response_schema('errors')
expect(errors_for(response)).to include "address-pou - can't be blank"
end
end
context 'when effective_end_date is included' do
let(:address) do
build(:va_profile_address, effective_end_date: Time.now.utc.iso8601)
end
it 'effective_end_date is NOT included in the request body', :aggregate_failures do
expect_any_instance_of(VAProfile::ContactInformation::V2::Service).to receive(:put_address) do |_, address|
expect(address.effective_end_date).to be_nil
end
put('/v0/profile/addresses', params: address.to_json, headers:)
end
end
context 'when non ASCII characters are used' do
it 'matches the error schema' do
address.address_line1 = '千代田区丸の'
put('/v0/profile/addresses', params: address.to_json, headers:)
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to match_response_schema('errors')
expect(errors_for(response)).to include 'address - must contain ASCII characters only'
end
end
end
describe 'DELETE /v0/profile/addresses' do
context 'when the method is DELETE' do
let(:frozen_time) { Time.zone.parse('2020-02-13T20:47:45.000Z') }
let(:address) do
{ 'address_line1' => '4041 Victoria Way',
'address_line2' => nil,
'address_line3' => nil,
'address_pou' => 'CORRESPONDENCE',
'address_type' => 'DOMESTIC',
'city' => 'Lexington',
'country_code_iso3' => 'USA',
'country_code_fips' => nil,
'county_code' => '21067',
'county_name' => 'Fayette County',
'created_at' => '2019-10-25T17:06:15.000Z',
'effective_end_date' => nil,
'effective_start_date' => '2020-02-10T17:40:15.000Z',
'id' => 138_225,
'international_postal_code' => nil,
'province' => nil,
'source_system_user' => nil,
'state_code' => 'KY',
'transaction_id' => '537b388e-344a-474e-be12-08d43cf35d69',
'updated_at' => '2020-02-10T17:40:25.000Z',
'override_validation_key' => nil,
'vet360_id' => '1',
'zip_code' => '40515',
'zip_code_suffix' => '4655' }
end
it 'effective_end_date gets appended to the request body', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/delete_address_success', VCR::MATCH_EVERYTHING) do
# The cassette we're using includes the effectiveEndDate in the body.
# So this test will not pass if it's missing
delete('/v0/profile/addresses', params: address.to_json, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('va_profile/transaction_response')
end
end
it 'effective_end_date gets appended to the request body when camel-inflected', :aggregate_failures do
VCR.use_cassette('va_profile/v2/contact_information/delete_address_success', VCR::MATCH_EVERYTHING) do
# The cassette we're using includes the effectiveEndDate in the body.
# So this test will not pass if it's missing
delete('/v0/profile/addresses', params: address.to_json, headers: headers_with_camel)
expect(response).to have_http_status(:ok)
expect(response).to match_camelized_response_schema('va_profile/transaction_response')
end
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/connected_applications_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'V0::Profile::ConnectedApplications', type: :request do
let(:user) { build(:user, :loa3, :legacy_icn) }
before { sign_in_as(user) }
context 'with valid response from okta' do
it 'returns list of grants by app' do
VCR.use_cassette('lighthouse/auth/client_credentials/connected_apps_200') do
get '/v0/profile/connected_applications'
expect(response).to have_http_status(:ok)
expect(response.body).to be_a(String)
expect(JSON.parse(response.body)['data'][0]['id']).to eq('0oa2ey2m6kEL2897N2p7')
end
end
it 'handle non-200 calls from lh auth' do
VCR.use_cassette('lighthouse/auth/client_credentials/connected_apps_400') do
get '/v0/profile/connected_applications'
expect(response).to have_http_status(:ok)
expect(response.body).to be_a(String)
expect(JSON.parse(response.body)['data'].length).to eq(0)
end
end
it 'deletes all the grants by app' do
VCR.use_cassette('lighthouse/auth/client_credentials/revoke_consent_204', allow_playback_repeats: true) do
delete '/v0/profile/connected_applications/0oa2ey2m6kEL2897N2p7'
expect(response).to have_http_status(:no_content)
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/profile/transactions_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'transactions' do
include SchemaMatchers
let(:user) { build(:user, :loa3, vet360_id: 1) }
before do
allow(VAProfile::Configuration::SETTINGS.contact_information).to receive(:cache_enabled).and_return(true)
user.vet360_contact_info
sign_in_as(user)
end
describe 'GET /v0/profile/status/:transaction_id' do
before do
Timecop.freeze('2024-08-28T18:51:06Z')
end
after do
Timecop.return
end
context 'when the requested transaction exists' do
context 'with a va profile transaction' do
it 'responds with a serialized transaction', :aggregate_failures do
transaction = create(
:va_profile_address_transaction,
user_uuid: user.uuid,
transaction_id: '0ea91332-4713-4008-bd57-40541ee8d4d4'
)
VCR.use_cassette('va_profile/v2/contact_information/address_transaction_status') do
get("/v0/profile/status/#{transaction.transaction_id}")
expect(response).to have_http_status(:ok)
response_body = JSON.parse(response.body)
expect(response_body['data']['type']).to eq('async_transaction_va_profile_address_transactions')
end
end
end
context 'with a vet360 transaction' do
it 'responds with a serialized transaction', :aggregate_failures do
transaction = create(
:address_transaction,
user_uuid: user.uuid,
transaction_id: '0ea91332-4713-4008-bd57-40541ee8d4d4'
)
VCR.use_cassette('va_profile/v2/contact_information/address_transaction_status') do
get("/v0/profile/status/#{transaction.transaction_id}")
expect(response).to have_http_status(:ok)
response_body = JSON.parse(response.body)
expect(response_body['data']['type']).to eq('async_transaction_va_profile_address_transactions')
# @TODO The ...data.attributes.type has the original, non-snake-cased version of the class
end
end
end
end
context 'when the transaction has messages' do
it 'messages are serialized in the metadata property', :aggregate_failures do
transaction = create(
:email_transaction,
user_uuid: user.uuid,
transaction_id: '5b4550b3-2bcb-4fef-8906-35d0b4b310a8'
)
VCR.use_cassette('va_profile/v2/contact_information/email_transaction_status') do
get("/v0/profile/status/#{transaction.transaction_id}")
expect(response).to have_http_status(:ok)
response_body = JSON.parse(response.body)
expect(response_body['data']['attributes']['metadata']).to be_a(Array)
end
end
end
context 'cache invalidation' do
it 'invalidates the cache for the va-profile-2-contact-info-response Redis key' do
VCR.use_cassette('va_profile/v2/contact_information/address_transaction_status') do
transaction = create(
:address_transaction,
user_uuid: user.uuid,
transaction_id: '0ea91332-4713-4008-bd57-40541ee8d4d4'
)
expect_any_instance_of(Common::RedisStore).to receive(:destroy)
get("/v0/profile/status/#{transaction.transaction_id}")
end
end
end
end
describe 'GET /v0/profile/status/' do
let(:user) { build(:user, :loa3) }
context 'when transaction(s) exists' do
context 'with va profile transactions' do
it 'responds with an array of transaction(s)', :aggregate_failures do
create(
:va_profile_address_transaction,
user_uuid: user.uuid,
transaction_id: '0ea91332-4713-4008-bd57-40541ee8d4d4'
)
create(
:va_profile_email_transaction,
user_uuid: user.uuid,
transaction_id: '5b4550b3-2bcb-4fef-8906-35d0b4b310a8'
)
VCR.use_cassette('va_profile/v2/contact_information/address_and_email_transaction_status') do
get('/v0/profile/status/')
expect(response).to have_http_status(:ok)
response_body = JSON.parse(response.body)
expect(response_body['data'].is_a?(Array)).to be(true)
expect(response_body['data'][0]['attributes']['type'])
.to eq('AsyncTransaction::VAProfile::AddressTransaction')
expect(response_body['data'][1]['attributes']['type'])
.to eq('AsyncTransaction::VAProfile::EmailTransaction')
end
end
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/my_va/submission_statuses_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'forms/submission_statuses/gateways/benefits_intake_gateway'
RSpec.describe 'V0::MyVA::SubmissionStatuses', feature: :form_submission,
team_owner: :vfs_authenticated_experience_backend, type: :request do
let(:user) { build(:user, :loa1) }
let(:account_id) { user.user_account_uuid }
let(:display_all_forms_toggle) { :my_va_display_all_lighthouse_benefits_intake_forms }
let(:benefits_intake_gateway) { Forms::SubmissionStatuses::Gateways::BenefitsIntakeGateway }
before do
sign_in_as(user)
end
context 'when user has submissions' do
before do
create(:form_submission, :with_form214142, user_account_id: account_id)
create(:form_submission, :with_form210845, user_account_id: account_id)
create(:form_submission, :with_form_blocked, user_account_id: account_id)
allow(Flipper[display_all_forms_toggle]).to receive(:enabled?).and_return(false)
end
it 'returns submission statuses' do
VCR.use_cassette('forms/submission_statuses/200_valid') do
get '/v0/my_va/submission_statuses'
end
expect(response).to have_http_status(:ok)
results = JSON.parse(response.body)['data']
expect(results.size).to eq(2)
end
it 'returns all fields' do
VCR.use_cassette('forms/submission_statuses/200_valid') do
get '/v0/my_va/submission_statuses'
end
expect(response).to have_http_status(:ok)
results = JSON.parse(response.body)['data']
keys = %w[id detail form_type message status created_at updated_at pdf_support]
expect(results.first['attributes'].keys.sort).to eq(keys.sort)
end
context 'when intake status response has an error' do
it 'responds with an errors collection' do
VCR.use_cassette('forms/submission_statuses/401_invalid') do
get '/v0/my_va/submission_statuses'
end
expect(response).to have_http_status(296)
keys = %w[status source title detail]
error = JSON.parse(response.body)['errors'].first
expect(error.keys.sort).to eq(keys.sort)
expect(error['source']).to eq('Lighthouse - Benefits Intake API')
end
end
context 'when intake status request is unauthorized' do
it 'responds with an unauthorized error message' do
VCR.use_cassette('forms/submission_statuses/401_invalid') do
get '/v0/my_va/submission_statuses'
end
expect(response).to have_http_status(296)
error = JSON.parse(response.body)['errors'].first
expect(error['status']).to eq(401)
expect(error['title']).to eq('Form Submission Status: Unauthorized')
end
end
context 'when the intake status request payload is too large' do
it 'responds with a request entity too large message' do
VCR.use_cassette('forms/submission_statuses/413_invalid') do
get '/v0/my_va/submission_statuses'
end
expect(response).to have_http_status(296)
error = JSON.parse(response.body)['errors'].first
expect(error['status']).to eq(413)
expect(error['title']).to eq('Form Submission Status: Request Entity Too Large')
end
end
context 'when the intake service is unable to process entity' do
it 'responds with an unprocessable content message' do
VCR.use_cassette('forms/submission_statuses/422_invalid') do
get '/v0/my_va/submission_statuses'
end
expect(response).to have_http_status(296)
error = JSON.parse(response.body)['errors'].first
expect(error['status']).to eq(422)
expect(error['title']).to eq('Form Submission Status: Unprocessable Content')
end
context 'when too many requests are sent to the intake service' do
it 'responds with a rate limit exceeded message' do
VCR.use_cassette('forms/submission_statuses/429_invalid') do
get '/v0/my_va/submission_statuses'
end
expect(response).to have_http_status(296)
error = JSON.parse(response.body)['errors'].first
expect(error['status']).to eq(429)
expect(error['title']).to eq('Form Submission Status: Too Many Requests')
end
end
end
context 'when an unexpected intake service server error occurs' do
it 'returns an internal server error' do
VCR.use_cassette('forms/submission_statuses/500_invalid') do
get '/v0/my_va/submission_statuses'
end
expect(response).to have_http_status(296)
error = JSON.parse(response.body)['errors'].first
expect(error['status']).to eq(500)
expect(error['title']).to eq('Form Submission Status: Internal Server Error')
end
end
context 'when the request to the intake service takes too long' do
it 'returns a getway timeout message' do
VCR.use_cassette('forms/submission_statuses/504_invalid') do
get '/v0/my_va/submission_statuses'
end
expect(response).to have_http_status(296)
error = JSON.parse(response.body)['errors'].first
expect(error['status']).to eq(504)
expect(error['title']).to eq('Form Submission Status: Gateway Timeout')
end
end
end
context 'with my_va_display_all_lighthouse_benefits_intake_forms toggle enabled' do
# Making sure it passed the benefits_intake_gateway#submission_recent? check
let(:two_days_ago) { 2.days.ago }
before do
create(:form_submission, :with_form214142, user_account_id: account_id, created_at: two_days_ago)
create(:form_submission, :with_form210845, user_account_id: account_id, created_at: two_days_ago)
create(:form_submission, :with_form_blocked, user_account_id: account_id, created_at: two_days_ago)
end
it 'returns all submission statuses including blocked forms' do
allow(Flipper[display_all_forms_toggle]).to receive(:enabled?).and_return(true)
VCR.use_cassette('forms/submission_statuses/200_valid_with_blocked_forms') do
get '/v0/my_va/submission_statuses'
end
expect(response).to have_http_status(:ok)
results = JSON.parse(response.body)['data']
expect(results.size).to eq(3)
end
end
context 'when user has lighthouse submissions' do
let!(:saved_claim) { create(:burials_saved_claim, :pending, user_account: user.user_account) }
before do
allow_any_instance_of(benefits_intake_gateway).to receive(:form_submissions).and_return([])
# Mock the Benefits Intake API response to avoid 401 errors
benefits_intake_uuid = saved_claim.lighthouse_submissions.first.submission_attempts.first.benefits_intake_uuid
lighthouse_intake_statuses = [
[{
'id' => benefits_intake_uuid,
'attributes' => {
'status' => 'pending',
'updated_at' => 1.day.ago,
'detail' => 'Processing burial claim',
'guid' => benefits_intake_uuid,
'message' => 'Form received and processing'
}
}],
nil
]
allow_any_instance_of(benefits_intake_gateway)
.to receive(:intake_statuses).and_return(lighthouse_intake_statuses)
allow(Flipper[display_all_forms_toggle]).to receive(:enabled?).and_return(false)
end
it 'returns lighthouse submission statuses' do
get '/v0/my_va/submission_statuses'
expect(response).to have_http_status(:ok)
results = JSON.parse(response.body)['data']
expect(results.size).to be >= 1
end
end
context 'when user has no submissions' do
before do
allow_any_instance_of(benefits_intake_gateway).to receive(:form_submissions).and_return([])
allow_any_instance_of(benefits_intake_gateway).to receive(:lighthouse_submissions).and_return([])
end
it 'returns an empty array' do
get '/v0/my_va/submission_statuses'
expect(response).to have_http_status(:ok)
results = JSON.parse(response.body)['data']
expect(results).to be_empty
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/my_va/submission_pdf_urls_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'simple_forms_api/form_remediation/configuration/vff_config'
require 'feature_flipper'
MOCK_URL = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
MOCK_404_URL = 'https://example.com/file1.pdf'
MOCK_GUID = '3b03b5a0-3ad9-4207-b61e-3a13ed1c8b80'
VALID_FORM_ID = '20-10206'
RSpec.describe 'V0::MyVA::SubmissionPdfUrls', feature: :form_submission,
team_owner: :vfs_authenticated_experience_backend,
type: :request do
let(:user) { build(:user, :loa1) }
let(:mock_config) { instance_double(SimpleFormsApi::FormRemediation::Configuration::VffConfig) }
before do
sign_in_as(user)
Flipper.enable('my_va_form_submission_pdf_link')
end
describe 'POST /v0/my_va/submission_pdf_urls' do
context 'when pdf download is available' do
before do
allow(SimpleFormsApi::FormRemediation::Configuration::VffConfig).to receive(:new).and_return(mock_config)
allow(SimpleFormsApi::FormRemediation::S3Client).to receive(:fetch_presigned_url).and_return(MOCK_URL)
end
it 'returns url for the archived pdf' do
VCR.use_cassette('my_va/submission_pdf_urls') do
post('/v0/my_va/submission_pdf_urls', params: { form_id: VALID_FORM_ID, submission_guid: MOCK_GUID })
end
expect(response).to have_http_status(:ok)
results = JSON.parse(response.body)
expect(results['url']).to eq(MOCK_URL)
end
end
context 'when pdf download is supposed to be available but does not exist in S3' do
before do
allow(SimpleFormsApi::FormRemediation::Configuration::VffConfig).to receive(:new).and_return(mock_config)
allow(SimpleFormsApi::FormRemediation::S3Client).to receive(:fetch_presigned_url).and_return(MOCK_404_URL)
end
it 'raises RecordNotFound error' do
VCR.use_cassette('my_va/submission_pdf_urls_404') do
post('/v0/my_va/submission_pdf_urls', params: { form_id: VALID_FORM_ID, submission_guid: MOCK_GUID })
end
expect(response).to have_http_status(:not_found)
end
end
context 'when pdf download is not available' do
before do
allow(SimpleFormsApi::FormRemediation::Configuration::VffConfig).to receive(:new).and_return(mock_config)
allow(SimpleFormsApi::FormRemediation::S3Client).to receive(:fetch_presigned_url).and_return(nil)
end
it 'raises Forbidden error if Form ID is not supported' do
post('/v0/my_va/submission_pdf_urls', params: { form_id: 'BAD_ID', submission_guid: MOCK_GUID })
expect(response).to have_http_status(:forbidden)
end
it 'raises RecordNotFound error if url result is not a string' do
post('/v0/my_va/submission_pdf_urls', params: { form_id: VALID_FORM_ID, submission_guid: MOCK_GUID })
expect(response).to have_http_status(:not_found)
end
it 'raises Validation error when given bad params' do
post('/v0/my_va/submission_pdf_urls', params: { f: VALID_FORM_ID, g: MOCK_GUID })
expect(response).to have_http_status(:bad_request)
end
it 'raises Validation error when missing a required param' do
post('/v0/my_va/submission_pdf_urls', params: { form_id: VALID_FORM_ID })
expect(response).to have_http_status(:bad_request)
end
it 'raises Validation error when given extra params' do
post('/v0/my_va/submission_pdf_urls', params: { form_id: VALID_FORM_ID, guid: MOCK_GUID, extra: 'boo!' })
expect(response).to have_http_status(:bad_request)
end
end
context 'when feature toggle is disabled' do
before do
Flipper.disable('my_va_form_submission_pdf_link')
end
it 'raises Forbidden error' do
post('/v0/my_va/submission_pdf_urls', params: { form_id: VALID_FORM_ID, guid: MOCK_GUID })
expect(response).to have_http_status(:forbidden)
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests/v0
|
code_files/vets-api-private/spec/requests/v0/form1010cg/attachments_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require_relative '../../../support/form1010cg_helpers/test_file_helpers'
RSpec.describe 'V0::Form1010CG::Attachments', type: :request do
let(:endpoint) { 'http://localhost:3000/v0/form1010cg/attachments' }
let(:headers) do
{
'ACCEPT' => 'application/json',
'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
'HTTP_X_KEY_INFLECTION' => 'camel'
}
end
let(:vcr_options) do
{
record: :none,
allow_unused_http_interactions: false,
match_requests_on: %i[method host body]
}
end
def make_upload_request_with(file_fixture_path, content_type)
request_options = {
headers:,
params: {
attachment: {
file_data: Form1010cgHelpers::TestFileHelpers.create_test_uploaded_file(file_fixture_path, content_type)
}
}
}
post(endpoint, **request_options)
end
describe 'POST /v0/form1010cg/attachments' do
after do
Form1010cg::Attachment.delete_all
end
context 'with JPG' do
let(:form_attachment_guid) { 'cdbaedd7-e268-49ed-b714-ec543fbb1fb8' }
before do
expect(SecureRandom).to receive(:uuid).and_call_original
expect(SecureRandom).to receive(:uuid).and_return(form_attachment_guid) # when FormAttachment is initalized
allow(SecureRandom).to receive(:uuid).and_call_original # Allow method to be called later in the req stack
end
it 'accepts a file upload' do
VCR.use_cassette "s3/object/put/#{form_attachment_guid}/doctors-note.jpg", vcr_options do
make_upload_request_with('doctors-note.jpg', 'image/jpg')
expect(response).to have_http_status(:ok)
res_body = JSON.parse(response.body)
expect(res_body['data']).to be_present
expect(res_body['data']['type']).to eq 'form1010cg_attachments'
expect(res_body['data']['id'].to_i).to be > 0
expect(res_body['data']['attributes']['guid']).to eq form_attachment_guid
end
end
end
context 'with PDF' do
let(:form_attachment_guid) { '834d9f51-d0c7-4dc2-9f2e-9b722db98069' }
before do
expect(SecureRandom).to receive(:uuid).and_call_original
expect(SecureRandom).to receive(:uuid).and_return(form_attachment_guid) # when FormAttachment is initalized
allow(SecureRandom).to receive(:uuid).and_call_original # Allow method to be called later in the req stack
end
it 'accepts a file upload' do
VCR.use_cassette "s3/object/put/#{form_attachment_guid}/doctors-note.pdf", vcr_options do
make_upload_request_with('doctors-note.pdf', 'application/pdf')
expect(response).to have_http_status(:ok)
res_body = JSON.parse(response.body)
expect(res_body['data']).to be_present
expect(res_body['data']['type']).to eq 'form1010cg_attachments'
expect(res_body['data']['id'].to_i).to be > 0
expect(res_body['data']['attributes']['guid']).to eq form_attachment_guid
end
end
end
end
end
|
0
|
code_files/vets-api-private/spec/requests
|
code_files/vets-api-private/spec/requests/authentication/standard_authentication_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
# Note these specs MUST be run in order
RSpec.describe 'authenticating loa3 user', order: :defined, type: :request do
OUTBOUND_CASSETTE = 'complex_interaction/external_interactions'
# rubocop:disable Lint/StructNewOverride
Episode = Struct.new(:method, :uri, :body, :headers, :recorded_at, :response)
# rubocop:enable Lint/StructNewOverride
EPISODES = begin
inbound_cassette_path = 'spec/support/vcr_cassettes/complex_interaction/internal_interactions.yml'
YAML.safe_load(File.read(inbound_cassette_path))['http_interactions'].map do |interaction|
req = interaction['request']
req['uri'] = URI.parse(req['uri'])
req['recorded_at'] = Time.zone.parse(interaction['recorded_at'].to_s).to_datetime
req['headers'] = req['headers'].transform_values(&:first)
Episode.new(*req.values, interaction['response'])
end
end
it 'does the tests', :aggregate_failures, :skip_mvi, skip: 'Unknown reason for skip' do
EPISODES.each_with_index do |episode, _index|
Timecop.freeze(episode.recorded_at) do
VCR.use_cassette(OUTBOUND_CASSETTE) do
SecureRandom.with_disabled_randomness do
make_request(episode)
end
end
end
expect(response.status).to eq(episode.response['status']['code'])
expect(response.body).to match_episode_body(episode.response['body']['string'])
expect(response.headers.keys).to match_episode_body(episode.response['headers'].keys)
end
end
private
def make_request(episode)
params = if episode.method == 'post'
Rack::Utils.parse_nested_query(episode.body['string'])
else
Rack::Utils.parse_nested_query(episode.uri.query)
end
send(episode.method, episode.uri.path, params, episode.headers)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/personal_information_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'va_profile/demographics/demographic_response'
RSpec.describe PersonalInformationSerializer, type: :serializer do
let(:demographics) { get_demographics }
let(:response) { serialize(demographics, serializer_class: described_class) }
let(:attributes) { JSON.parse(response)['data']['attributes'] }
context 'when gender is nil' do
it 'returns nil for gender' do
expect(attributes['gender']).to be_nil
end
end
context 'when birth_date is nil' do
it 'returns nil for birth_date' do
expect(attributes['birth_date']).to be_nil
end
end
private
def get_demographics(attributes = {})
VAProfile::Demographics::DemographicResponse.from(
status: 200,
body: nil,
id: '12345',
type: 'mvi_models_mvi_profiles',
gender: attributes[:gender],
birth_date: attributes[:birth_date]
)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/rating_info_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'evss/disability_compensation_form/rating_info_response'
describe RatingInfoSerializer, type: :serializer do
subject { serialize(rating_info_response, serializer_class: described_class) }
let(:rating_info_response) do
response = double('response', body: { user_percent_of_disability: 100 })
EVSS::DisabilityCompensationForm::RatingInfoResponse.new(200, response)
end
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :user_percent_of_disability' do
expect(attributes['user_percent_of_disability']).to eq rating_info_response.user_percent_of_disability
end
it 'includes :source_system' do
expect(attributes['source_system']).to eq 'EVSS'
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/onsite_notification_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe OnsiteNotificationSerializer, type: :serializer do
subject { serialize(notification, serializer_class: described_class) }
let(:notification) { build_stubbed(:onsite_notification) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq notification.id.to_s
end
it 'includes :template_id' do
expect(attributes['template_id']).to eq notification.template_id
end
it 'includes :va_profile_id' do
expect(attributes['va_profile_id']).to eq notification.va_profile_id
end
it 'includes :dismissed' do
expect(attributes['dismissed']).to eq notification.dismissed
end
it 'includes :created_at' do
expect_time_eq(attributes['created_at'], notification.created_at)
end
it 'includes :updated_at' do
expect_time_eq(attributes['updated_at'], notification.updated_at)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/health_care_application_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe HealthCareApplicationSerializer, type: :serializer do
subject { serialize(application, serializer_class: described_class) }
let(:application) { build_stubbed(:health_care_application, :with_success) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq application.id.to_s
end
it 'includes :type' do
expect(data['type']).to eq 'health_care_applications'
end
it 'includes :state' do
expect(attributes['state']).to eq application.state
end
it 'includes :form_submission_id' do
expect(attributes['form_submission_id']).to eq application.form_submission_id
end
it 'includes :timestamp' do
expect(attributes['timestamp']).to eq application.timestamp
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/intent_to_file_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'disability_compensation/responses/intent_to_files_response'
describe IntentToFileSerializer, type: :serializer do
subject { serialize(itf_response, serializer_class: described_class) }
let(:intent_to_file) { build_stubbed(:disability_compensation_intent_to_file) }
let(:itf_response) { DisabilityCompensation::ApiProvider::IntentToFileResponse.new(intent_to_file:) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :intent_to_file' do
expect(attributes['intent_to_file']).to be_present
end
it 'includes :intent_to_file with attributes' do
expected_attributes = intent_to_file.attributes.keys.map(&:to_s)
expect(attributes['intent_to_file'].keys).to match_array(expected_attributes)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/user_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe UserSerializer do
subject { serialize(pre_serialized_profile, serializer_class: described_class) }
let(:user) { create(:user, :loa3) }
let!(:in_progress_form) { create(:in_progress_form, user_uuid: user.uuid) }
let(:pre_serialized_profile) { Users::Profile.new(user).pre_serialize }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
context 'when initialized with an object that cannot be called by each of the attributes' do
it 'raises an error' do
expect { serialize(user, serializer_class: described_class) }.to raise_error(NoMethodError)
end
end
it 'returns serialized #services data' do
expect(attributes['services']).to eq pre_serialized_profile.services
end
it 'returns serialized #user_account data' do
expect(attributes['user_account']).to eq JSON.parse(pre_serialized_profile.user_account.to_json)
end
it 'returns serialized #profile data' do
expect(attributes['profile']).to eq JSON.parse(pre_serialized_profile.profile.to_json)
end
it 'returns serialized #va_profile data' do
expect(attributes['va_profile']).to eq pre_serialized_profile.va_profile.deep_stringify_keys
end
it 'returns serialized #onboarding data' do
expect(attributes['onboarding']).to eq pre_serialized_profile.onboarding.deep_stringify_keys
end
it 'returns serialized #veteran_status data' do
VCR.use_cassette('va_profile/veteran_status/va_profile_veteran_status_200', match_requests_on: %i[body],
allow_playback_repeats: true) do
expect(attributes['veteran_status']).to eq pre_serialized_profile.veteran_status.deep_stringify_keys
end
end
it 'returns serialized #in_progress_forms data' do
in_progress_form = pre_serialized_profile.in_progress_forms.first.deep_stringify_keys
expect(attributes['in_progress_forms'].first).to eq in_progress_form
end
it 'returns serialized #prefills_available data' do
expect(attributes['prefills_available']).to eq pre_serialized_profile.prefills_available
end
it 'returns serialized #vet360_contact_information data' do
vet360_contact_information = JSON.parse(pre_serialized_profile.vet360_contact_information.to_json)
expect(attributes['vet360_contact_information']).to eq vet360_contact_information
end
it 'returns serialized #session data' do
expect(attributes['session']).to eq pre_serialized_profile.session.deep_stringify_keys
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/education_benefits_claim_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe EducationBenefitsClaimSerializer do
subject { serialize(education_benefits_claim) }
let(:education_benefits_claim) { create(:education_benefits_claim) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes id' do
expect(data['id']).to eq(education_benefits_claim.token)
end
%w[form regional_office confirmation_number].each do |attr|
it "includes #{attr}" do
expect(attributes[attr]).to eq(education_benefits_claim.public_send(attr))
end
end
it 'does not include any extra attributes' do
expect(attributes.keys).to eq(%w[form regional_office confirmation_number])
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/form526_job_status_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe Form526JobStatusSerializer, type: :serializer do
subject { serialize(form526_job_status, serializer_class: described_class) }
let(:form526_job_status) { create(:form526_job_status) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :type' do
expect(data['type']).to eq 'form526_job_statuses'
end
it 'includes :claim_id' do
expect(attributes['claim_id']).to eq form526_job_status.submission.submitted_claim_id
end
it 'includes :submission_id' do
expect(attributes['submission_id']).to eq form526_job_status.submission.id
end
it 'includes :ancillary_item_statuses' do
expected_statuses = form526_job_status.submission.form526_job_statuses.map do |status|
status.attributes.except('form526_submission_id') unless status.id == form526_job_status.id
end.compact
expect(attributes['ancillary_item_statuses'].first['id']).to eq expected_statuses.first['id']
expect(attributes['ancillary_item_statuses'].first.keys).not_to include('form526_submission_id')
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/evss_claim_detail_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require_relative 'shared_examples_evss_claim_spec'
RSpec.describe EVSSClaimDetailSerializer, type: :serializer do
subject { serialize(evss_claim, serializer_class: described_class) }
let(:evss_claim) { build(:evss_claim) }
let(:data) { JSON.parse(subject)['data'] }
let(:object_data) { evss_claim.data }
let(:attributes) { data['attributes'] }
it_behaves_like 'shared_evss_claim'
it 'includes :contention_list' do
expect(attributes['contention_list']).to eq(evss_claim.data['contention_list'])
end
it 'includes :va_representative' do
sanitized_va_rep = ActionView::Base.full_sanitizer.sanitize(evss_claim.data['poa'])&.gsub(/&[^ ;]+;/, '')
expect(attributes['va_representative']).to eq(sanitized_va_rep)
end
it 'includes events_timeline' do
expect(attributes['events_timeline']).to be_an(Array)
end
context 'with HTML in the description' do
let(:claim_data) do
{
claim_tracked_items: {
still_need_from_you_list: [
{
description: 'this has <h1>HTML</h1>'
}
]
}
}
end
let(:evss_claim) { build(:evss_claim, data: claim_data) }
it 'strips the HTML tags' do
expect(attributes['events_timeline'][0]['description']).to eq('this has HTML')
end
end
context 'with HTML in the VA representative field' do
let(:evss_claim) { build(:evss_claim, data: { poa: '<VATreatmentCenter>' }) }
it 'strips the HTML tags' do
expect(attributes['va_representative']).to eq('VATreatmentCenter')
end
end
context 'with different data and list_data' do
let(:claim_data) { { waiver5103_submitted: true } }
let(:claim_list_data) { { waiver5103_submitted: false } }
let(:evss_claim) { build(:evss_claim, data: claim_data, list_data: claim_list_data) }
it 'does not use list_data' do
expect(attributes['waiver_submitted']).to be true
end
end
context 'with items in vbaDocuments' do
let(:raw_data) do
fixture_file_name = Rails.root.join(
*'/spec/fixtures/evss_claim/claim-with-documents.json'.split('/')
).to_s
File.open(fixture_file_name, 'rb') do |f|
raw_claim = f.read
JSON.parse(raw_claim).deep_transform_keys!(&:underscore)
end
end
let(:evss_claim) { build(:evss_claim, data: raw_data) }
it 'only adds documents without a tracked_item_id into other_documents_list' do
other_documents = attributes['events_timeline'].select { |obj| obj['type'] == 'other_documents_list' }
expect(other_documents.count).to eq 1
expect(other_documents.reject { |obj| obj['tracked_item_id'].nil? }.count).to eq 0
end
it 'uses the upload date for the tracked item' do
tracked_item = attributes['events_timeline'].detect { |event| event['tracked_item_id'] == 211_684 }
expect(tracked_item['date']).to eq('2016-11-04')
end
end
context 'with some phase dates' do
let(:date_str) { Date.new(2012, 8, 10).to_json[1...-1] }
it 'does not have a phase 1..6 event' do
(1..6).each do |i|
expect(attributes['events_timeline'].select { |obj| obj['type'] == "phase#{i}" }.count).to eq 0
end
end
it 'has a phase 7 event' do
expect(attributes['events_timeline'].select { |obj| obj['type'] == 'phase7' }.count).to eq 1
end
it 'has the right date for phase 7' do
expect(attributes['events_timeline'].select { |obj| obj['type'] == 'phase7' }.first['date']).to eq date_str
end
end
it 'includes :phase' do
phase = evss_claim.data.dig('claim_phase_dates', 'latest_phase_type')&.downcase
expect(attributes['phase']).to eq EVSSClaimBaseHelper::PHASE_MAPPING[phase]
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/contact_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe ContactSerializer, type: :serializer do
subject { serialize(contact, serializer_class: described_class) }
let(:contact) { build_stubbed(:associated_person) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id as contact_type' do
expect(data['id']).to eq contact.contact_type
end
it 'includes :contact_type' do
expect(attributes['contact_type']).to eq contact.contact_type
end
it 'includes :given_name' do
expect(attributes['given_name']).to eq contact.given_name
end
it 'includes :middle_name' do
expect(attributes['middle_name']).to eq contact.middle_name
end
it 'includes :family_name' do
expect(attributes['family_name']).to eq contact.family_name
end
it 'includes :relationship' do
expect(attributes['relationship']).to eq contact.relationship
end
it 'includes :address_line1' do
expect(attributes['address_line1']).to eq contact.address_line1
end
it 'includes :address_line2' do
expect(attributes['address_line2']).to eq contact.address_line2
end
it 'includes :address_line3' do
expect(attributes['address_line3']).to eq contact.address_line3
end
it 'includes :city' do
expect(attributes['city']).to eq contact.city
end
it 'includes :state' do
expect(attributes['state']).to eq contact.state
end
it 'includes :zip_code' do
expect(attributes['zip_code']).to eq contact.zip_code
end
it 'includes :primary_phone' do
expect(attributes['primary_phone']).to eq contact.primary_phone
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/service_history_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe ServiceHistorySerializer, type: :serializer do
subject { serialize(service_history, { serializer_class: described_class, is_collection: false }) }
let(:service_history) do
histories = {
episodes: [build(:service_history, :with_deployments)],
vet_status_eligibility: { confirmed: true, message: [] }
}
JSON.parse(histories.to_json, symbolize_names: true)
end
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :service_history' do
expect(attributes['service_history'].size).to eq service_history[:episodes].size
end
it 'includes :service_history with attributes' do
expect(attributes['service_history'].first).to eq service_history[:episodes].first.deep_stringify_keys
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/full_name_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe FullNameSerializer, type: :serializer do
subject { serialize(full_name, serializer_class: described_class) }
let(:full_name) { { first: 'John', middle: 'Steven', last: 'Doe', suffix: 'Jr' } }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :first' do
expect(attributes['first']).to eq full_name[:first]
end
it 'includes :middle' do
expect(attributes['middle']).to eq full_name[:middle]
end
it 'includes :last' do
expect(attributes['last']).to eq full_name[:last]
end
it 'includes :suffix' do
expect(attributes['suffix']).to eq full_name[:suffix]
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/rated_disabilities_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe RatedDisabilitiesSerializer, type: :serializer do
subject { serialize(rated_disabilities_response, serializer_class: described_class) }
let(:rated_disabilities_response) { build(:rated_disabilities_response) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
let(:links) { data['links'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :rated_disabilities' do
expect(attributes['rated_disabilities'].size).to eq rated_disabilities_response.rated_disabilities.size
end
it 'includes :rated_disabilities with attributes' do
expected_attributes = rated_disabilities_response.rated_disabilities.first.attributes.keys.map(&:to_s)
expect(attributes['rated_disabilities'].first.keys).to eq expected_attributes
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/user_verification_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe UserVerificationSerializer do
subject { described_class.new(user_verification:).perform }
let(:user_verification) { build(:user_verification) }
it 'returns the serialized verification CSP type' do
expect(subject[:type]).to eq(user_verification.credential_type)
end
it 'returns the serialized verification credential_id' do
expect(subject[:credential_id]).to eq(user_verification.credential_identifier)
end
it 'returns the serialized verification locked status' do
expect(subject[:locked]).to eq(user_verification.locked)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/preneed_attachment_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe PreneedAttachmentSerializer, type: :serializer do
subject { serialize(attachment, serializer_class: described_class) }
let(:attachment) { build_stubbed(:preneed_attachment) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq attachment.id.to_s
end
it 'includes :guid' do
expect(attributes['guid']).to eq attachment.guid
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/dependents_verifications_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe DependentsVerificationsSerializer, type: :serializer do
subject { serialize(dependent_verifications, serializer_class: described_class) }
let(:dependent_verifications) { build_stubbed(:dependent_verifications) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
describe 'dependency_verifications' do
context 'when dependency_decs is a hash' do
let(:dependency_decs) { build(:dependency_dec) }
let(:dependent_verifications) { build(:dependent_verifications, dependency_decs:) }
it 'includes :dependency_dec as an array' do
expect(attributes['dependency_verifications'].size).to eq 1
end
end
context 'when dependency_decs is an array' do
let(:dependency_decs) { build_list(:dependency_dec, 2) }
let(:dependent_verifications) { build(:dependent_verifications, dependency_decs:) }
it 'includes :dependency_dec' do
expect(attributes['dependency_verifications'].size).to eq dependency_decs.size
end
end
it 'does not include :social_sercurity_number' do
expect(attributes['dependency_verifications'].first).not_to include(:social_security_number)
end
end
describe 'prompt_renewal' do
context 'when there are multiple entries in the diaries call' do
let(:dependent_verifications) { build(:dependent_verifications, :multiple_entries) }
it "returns true when at least one has a diary_reason_type of '24'
AND a diary_lc_status_type of 'PEND' AND the due_date is within 7 years" do
expect(attributes['prompt_renewal']).to be true
end
end
context 'when there is one entry in the diaries call' do
let(:dependent_verifications) { build(:dependent_verifications) }
it "returns true when it has a diary_reason_type of '24'
AND a diary_lc_status_type of 'PEND' AND the due_date is within 7 years" do
expect(attributes['prompt_renewal']).to be true
end
context 'and the due_date is in the future' do
let(:cassette_due_date) { Time.zone.parse('2014-05-01T00:00:00-05:00') }
before { Timecop.freeze(cassette_due_date - time_jump) }
after { Timecop.return }
context 'by 6 years and 11 months' do
let(:time_jump) { 6.years + 11.months }
let(:dependent_verifications) { build(:dependent_verifications) }
it 'returns true when the diary_entry is due less than 7 years from now' do
expect(attributes['prompt_renewal']).to be true
end
end
context 'by 7 years and 1 day' do
let(:time_jump) { 7.years + 1.day }
let(:dependent_verifications) { build(:dependent_verifications, :due_in_7_years_1_day) }
it 'returns false when the diary_entry is due more than 7 years from now' do
expect(attributes['prompt_renewal']).to be false
end
end
end
end
context 'when there are no entries in the diaries call' do
let(:dependent_verifications) { build(:dependent_verifications, :no_entries) }
it 'returns false' do
expect(attributes['prompt_renewal']).to be false
end
end
context "when the entry has a status of 'CXCL'" do
let(:dependent_verifications) { build(:dependent_verifications, :status_type_cxcl) }
it 'returns false' do
expect(attributes['prompt_renewal']).to be false
end
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/dependents_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe DependentsSerializer, type: :serializer do
subject { serialize(dependents, serializer_class: described_class) }
let(:person_id) { '600140899' }
let(:person) do
{
award_indicator: 'N',
date_of_birth: '01/02/1960',
email_address: 'test@email.com',
first_name: 'JANE',
last_name: 'WEBB',
middle_name: 'M',
ptcpnt_id: '600140899',
related_to_vet: 'Y',
relationship: 'Spouse',
ssn: '222883214',
veteran_indicator: 'N'
}
end
let(:expiring_diary) do
{
person_id:,
dependency_decision_type: 'T18',
dependency_decision_type_description: 'Turns 18',
dependency_status_type_description: 'Not an Award Dependent',
award_effective_date: 2.days.from_now.iso8601
}
end
let(:current_diary) do
{
person_id:,
dependency_decision_type: 'EMC',
dependency_decision_type_description: 'Eligible Minor Child',
dependency_status_type_description: 'Minor Child',
award_effective_date: 2.years.ago.iso8601
}
end
let(:dependents) do
{
number_of_records: '2',
persons: [person],
return_code: 'SHAR 9999',
return_message: 'Records found',
diaries: {
dependency_decs: [expiring_diary,
current_diary]
}
}
end
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
context 'when persons is a hash' do
let(:persons_hash) do
{
number_of_records: '2',
persons: person,
return_code: 'SHAR 9999',
return_message: 'Records found',
diaries: {}
}
end
let(:response_persons_hash) { serialize(persons_hash, serializer_class: described_class) }
let(:attributes_persons_hash) { JSON.parse(response_persons_hash)['data']['attributes'] }
it 'includes :persons as an Array' do
expect(attributes_persons_hash['persons']).to be_a(Array)
expect(attributes_persons_hash['persons'].size).to eq 1
end
end
context 'when persons is an array' do
it 'includes :persons' do
expect(attributes['persons']).to be_a(Array)
expect(attributes['persons'].size).to eq dependents[:persons].size
end
end
it 'includes person with attributes' do
expect(attributes['persons'].first).to include(
'award_indicator' => 'N',
'date_of_birth' => '01/02/1960',
'email_address' => 'test@email.com',
'first_name' => 'JANE',
'last_name' => 'WEBB',
'middle_name' => 'M',
'ptcpnt_id' => '600140899',
'related_to_vet' => 'Y',
'relationship' => 'Spouse',
'ssn' => '222883214',
'veteran_indicator' => 'N'
)
end
context 'upcoming removal date within range' do
it 'returns date and reason' do
expect(attributes['persons'].first).to include('upcoming_removal_date')
expect(attributes['persons'].first).to include('upcoming_removal_reason' => 'Turns 18')
end
end
context 'upcoming removal expired' do
let(:expiring_diary) do
{
person_id:,
dependency_decision_type: 'T18',
dependency_decision_type_description: 'Turns 18',
dependency_status_type_description: 'Not an Award Dependent',
award_effective_date: 2.days.ago.iso8601
}
end
it 'does not return expired date and reason' do
expect(attributes['persons'].first['upcoming_removal_date']).to be_nil
expect(attributes['persons'].first['upcoming_removal_reason']).to be_nil
end
it 'does not display current benefits date and reason' do
expect(attributes['persons'].first['dependent_benefit_type']).to be_nil
end
end
context 'current benefits within range' do
it 'returns benefits description' do
expect(attributes['persons'].first).to include('dependent_benefit_type' => 'Minor Child')
end
end
context 'current benefits out of range' do
let(:current_diary) do
{
person_id:,
dependency_decision_type: 'EMC',
dependency_decision_type_description: 'Eligible Minor Child',
dependency_status_type_description: 'Minor Child',
award_effective_date: 2.days.from_now.iso8601
}
end
it 'does not return date and reason' do
expect(attributes['persons'].first['dependent_benefit_type']).to be_nil
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/scheduling_preferences_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe SchedulingPreferencesSerializer, type: :serializer do
subject { serialize(scheduling_preferences, serializer_class: described_class) }
let(:scheduling_preferences) do
{
preferences: [
{ item_id: 1, option_ids: [5] },
{ item_id: 2, option_ids: [7, 11] }
]
}
end
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :type' do
expect(data['type']).to eq('scheduling_preferences')
end
it 'includes :preferences' do
expected_preferences = [
{ 'item_id' => 1, 'option_ids' => [5] },
{ 'item_id' => 2, 'option_ids' => [7, 11] }
]
expect(attributes['preferences']).to eq(expected_preferences)
end
it 'serializes preferences array structure' do
preferences = attributes['preferences']
expect(preferences).to be_an(Array)
expect(preferences.length).to eq(2)
first_preference = preferences.first
expect(first_preference['item_id']).to eq(1)
expect(first_preference['option_ids']).to eq([5])
second_preference = preferences.last
expect(second_preference['item_id']).to eq(2)
expect(second_preference['option_ids']).to eq([7, 11])
end
context 'when preferences array is empty' do
let(:scheduling_preferences) { { preferences: [] } }
it 'includes empty preferences array' do
expect(attributes['preferences']).to eq([])
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/gi_bill_feedback_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe GIBillFeedbackSerializer, type: :serializer do
subject { serialize(feedback, serializer_class: described_class) }
let(:feedback) { build_stubbed(:gi_bill_feedback, :with_response) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq feedback.id
end
it 'includes :guid' do
expect(attributes['guid']).to eq feedback.guid
end
it 'includes :state' do
expect(attributes['state']).to eq feedback.state
end
it 'includes :parsed_response' do
expect(attributes['parsed_response']).to eq feedback.parsed_response
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/lighthouse_rating_info_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe LighthouseRatingInfoSerializer, type: :serializer do
subject { serialize(rating_info, serializer_class: described_class) }
let(:rating_info) { { user_percent_of_disability: 100 } }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :user_percent_of_disability' do
expect(attributes['user_percent_of_disability']).to eq rating_info[:user_percent_of_disability]
end
it 'includes :source_system' do
expect(attributes['source_system']).to eq 'Lighthouse'
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/cemetery_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe CemeterySerializer do
subject { serialize(cemetery, serializer_class: described_class) }
let(:cemetery) { build(:cemetery) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq(cemetery.id)
end
it 'includes :type' do
expect(data['type']).to eq('preneeds_cemeteries')
end
it 'includes :cemetery_id' do
expect(attributes['cemetery_id']).to eq(cemetery.id)
end
it 'includes :num' do
expect(attributes['num']).to eq(cemetery.num)
end
it 'includes :cemetery_type' do
expect(attributes['cemetery_type']).to eq(cemetery.cemetery_type)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/persistent_attachment_va_form_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe PersistentAttachmentVAFormSerializer, type: :serializer do
subject { serialize(attachment, serializer_class: described_class) }
# requires create instead of build for the attached file
let(:attachment) { create(:va_form_pdf) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq attachment.id.to_s
end
it 'includes :confirmation_code' do
expect(attributes['confirmation_code']).to eq attachment.guid
end
it 'includes :name' do
expect(attributes['name']).to eq attachment.original_filename
end
it 'includes :size' do
expect(attributes['size']).to eq attachment.size
end
it 'includes :warnings' do
expect(attributes['warnings']).to eq attachment.warnings
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/search_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'search/response'
describe SearchSerializer, type: :serializer do
subject { serialize(search_response, serializer_class: described_class) }
let(:search_attributes) { { body: { query: 'benefits' } } }
let(:search_response) do
pagination = { current_page: 1, per_page: 10, total_pages: 9, total_entries: 85 }
Search::ResultsResponse.new(200, pagination, search_attributes)
end
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :body' do
expect(attributes['body']).to eq search_attributes[:body].deep_stringify_keys
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/receive_application_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ReceiveApplicationSerializer do
subject { serialize(receive_application, serializer_class: described_class) }
let(:receive_application) { build(:receive_application) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq(receive_application.receive_application_id)
end
it 'includes :type' do
expect(data['type']).to eq('preneeds_receive_applications')
end
it 'includes :tracking_number as attribute' do
expect(attributes['tracking_number']).to eq(receive_application.tracking_number)
end
it 'includes :submitted_at as attribute' do
expect(attributes['submitted_at']).to eq(receive_application.submitted_at.iso8601(3))
end
it 'includes :return_code as attribute' do
expect(attributes['return_code']).to eq(receive_application.return_code)
end
it 'includes :application_uuid as attribute' do
expect(attributes['application_uuid']).to eq(receive_application.application_uuid)
end
it 'includes :return_description as attribute' do
expect(attributes['return_description']).to eq(receive_application.return_description)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/evss_claim_list_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require_relative 'shared_examples_evss_claim_spec'
RSpec.describe EVSSClaimListSerializer, type: :serializer do
subject { serialize(evss_claim, serializer_class: described_class) }
let(:evss_claim) { build(:evss_claim) }
let(:data) { JSON.parse(subject)['data'] }
let(:object_data) { evss_claim.list_data }
let(:attributes) { data['attributes'] }
it_behaves_like 'shared_evss_claim'
it 'includes :phase' do
phase = evss_claim.list_data['status']&.downcase
expect(attributes['phase']).to eq EVSSClaimBaseHelper::PHASE_MAPPING[phase]
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/extract_status_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe ExtractStatusSerializer, type: :serializer do
subject { serialize(extract_status, serializer_class: described_class) }
let(:extract_status) { build_stubbed(:extract_status) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq extract_status.id
end
it 'includes :type' do
expect(data['type']).to eq 'extract_statuses'
end
it 'includes :extract_type' do
expect(attributes['extract_type']).to eq extract_status.extract_type
end
it 'includes :last_updated' do
expect_time_eq(attributes['last_updated'], extract_status.last_updated)
end
it 'includes :status' do
expect(attributes['status']).to eq extract_status.status
end
it 'includes :created_on' do
expect_time_eq(attributes['created_on'], extract_status.created_on)
end
it 'includes :station_number' do
expect(attributes['station_number']).to eq extract_status.station_number
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/valid_va_file_number_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe ValidVAFileNumberSerializer, type: :serializer do
subject { serialize(file_number, serializer_class: described_class) }
let(:file_number) { { file_nbr: true } }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :valid_va_file_number' do
expect(attributes['valid_va_file_number']).to eq file_number[:file_nbr]
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/in_progress_form_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe InProgressFormSerializer do
subject { serialize(in_progress_form, serializer_class: described_class) }
let(:in_progress_form) { build(:in_progress_form) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
let(:metadata) { attributes['metadata'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :type' do
expect(data['type']).to eq 'in_progress_forms'
end
it 'includes :createdAt' do
expect(attributes['createdAt']).to eq in_progress_form.created_at
end
it 'includes :metadata' do
expect(metadata).to eq in_progress_form.metadata
end
context 'with nested metadata' do
it 'keep the original case of metadata' do
expect(metadata).to eq in_progress_form.metadata
expect(metadata.keys).to eq(in_progress_form.metadata.keys)
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/gender_identity_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'va_profile/demographics/gender_identity_response'
describe GenderIdentitySerializer, type: :serializer do
subject { serialize(gender_identity_response, serializer_class: described_class) }
let(:gender_identity) { VAProfile::Models::GenderIdentity.new(code: 'F', name: 'Female') }
let(:gender_identity_response) { VAProfile::Demographics::GenderIdentityResponse.new(200, gender_identity:) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :gender_identity' do
gender_identity_attributes = gender_identity_response.gender_identity.attributes.deep_stringify_keys
expect(attributes['gender_identity']).to eq gender_identity_attributes
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/disability_contention_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe DisabilityContentionSerializer, type: :serializer do
subject { serialize(contention, serializer_class: described_class) }
let(:contention) { build_stubbed(:disability_contention_arrhythmia) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq contention.id.to_s
end
it 'includes :code' do
expect(attributes['code']).to eq contention.code
end
it 'includes :medical_term' do
expect(attributes['medical_term']).to eq contention.medical_term
end
it 'includes :lay_term' do
expect(attributes['lay_term']).to eq contention.lay_term
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/mhv_user_account_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe MHVUserAccountSerializer, type: :serializer do
subject { serialize(mhv_user_account, serializer_class: described_class) }
let(:mhv_user_account) { MHVUserAccount.new(mhv_response) }
let(:mhv_response) do
{
user_profile_id: '123456',
premium: true,
champ_va: true,
patient: true,
sm_account_created: true,
message: 'some-message'
}
end
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq mhv_response[:user_profile_id]
end
it 'includes :user_profile_id' do
expect(attributes['user_profile_id']).to eq mhv_response[:user_profile_id]
end
it 'includes :premium' do
expect(attributes['premium']).to eq mhv_response[:premium]
end
it 'includes :champ_va' do
expect(attributes['champ_va']).to eq mhv_response[:champ_va]
end
it 'includes :patient' do
expect(attributes['patient']).to eq mhv_response[:patient]
end
it 'includes :sm_account_created' do
expect(attributes['sm_account_created']).to eq mhv_response[:sm_account_created]
end
it 'includes :message' do
expect(attributes['message']).to eq mhv_response[:message]
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/form1010_ezr_attachment_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'support/1010_forms/shared_examples/attachment_serializer'
describe Form1010EzrAttachmentSerializer, type: :serializer do
it_behaves_like '1010 forms attachment serializer' do
let(:resource_name) { 'form1010_ezr_attachment' }
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/separation_location_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe SeparationLocationSerializer, type: :serializer do
subject { described_class.new(intake_sites_response).to_json }
let(:separation_locations) do
[
DisabilityCompensation::ApiProvider::SeparationLocation.new(code: 98_283, description: 'AF Academy'),
DisabilityCompensation::ApiProvider::SeparationLocation.new(code: 123_558, description: 'ANG Hub'),
DisabilityCompensation::ApiProvider::SeparationLocation.new(code: 98_282, description: 'Aberdeen Proving Ground')
]
end
let(:intake_sites_response) do
DisabilityCompensation::ApiProvider::IntakeSitesResponse.new(status: 200, separation_locations:)
end
let(:data) { JSON.parse(subject) }
let(:attributes) { data['attributes'] }
it 'includes :status' do
expect(data['status']).to eq intake_sites_response.status
end
it 'includes :separation_locations as an array' do
expect(data['separation_locations'].size).to eq intake_sites_response.separation_locations.size
expect(data['separation_locations'].first['code']).to eq intake_sites_response.separation_locations.first.code
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/post911_gi_bill_status_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe Post911GIBillStatusSerializer, type: :serializer do
subject { serialize(gi_bill_status, serializer_class: described_class) }
let(:gi_bill_status) { build(:gi_bill_status_response) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :first_name' do
expect(attributes['first_name']).to eq gi_bill_status.first_name
end
it 'includes :last_name' do
expect(attributes['last_name']).to eq gi_bill_status.last_name
end
it 'includes :name_suffix' do
expect(attributes['name_suffix']).to eq gi_bill_status.name_suffix
end
it 'includes :date_of_birth' do
expect(attributes['date_of_birth']).to eq gi_bill_status.date_of_birth
end
it 'includes :va_file_number' do
expect(attributes['va_file_number']).to eq gi_bill_status.va_file_number
end
it 'includes :regional_processing_office' do
expect(attributes['regional_processing_office']).to eq gi_bill_status.regional_processing_office
end
it 'includes :eligibility_date' do
expect(attributes['eligibility_date']).to eq gi_bill_status.eligibility_date
end
it 'includes :delimiting_date' do
expect(attributes['delimiting_date']).to eq gi_bill_status.delimiting_date
end
it 'includes :percentage_benefit' do
expect(attributes['percentage_benefit']).to eq gi_bill_status.percentage_benefit
end
it 'includes :original_entitlement' do
expect_entitlement(attributes['original_entitlement'], gi_bill_status.original_entitlement)
end
it 'includes :used_entitlement' do
expect_entitlement(attributes['used_entitlement'], gi_bill_status.used_entitlement)
end
it 'includes :remaining_entitlement' do
expect_entitlement(attributes['remaining_entitlement'], gi_bill_status.remaining_entitlement)
end
it 'includes :active_duty' do
expect(attributes['active_duty']).to eq gi_bill_status.active_duty
end
it 'includes :veteran_is_eligible' do
expect(attributes['veteran_is_eligible']).to eq gi_bill_status.veteran_is_eligible
end
it 'includes :enrollments' do
expect(attributes['enrollments'].size).to eq gi_bill_status.enrollments.size
end
it 'includes :enrollments with attributes' do
expected_attributes = gi_bill_status.enrollments.first.attributes.keys.map(&:to_s)
expect(attributes['enrollments'].first.keys).to eq expected_attributes
end
context 'enrollment' do
let(:enrollment) { attributes['enrollments'].first }
it 'includes :amendments' do
expect(enrollment['amendments'].size).to eq gi_bill_status.enrollments.first.amendments.size
end
it 'includes :amendments with attributes' do
expected_attributes = gi_bill_status.enrollments.first.amendments.first.attributes.keys.map(&:to_s)
expect(enrollment['amendments'].first.keys).to eq expected_attributes
end
end
private
def expect_entitlement(serialized_entitlement, entitlement)
expect(serialized_entitlement).to eq(
'months' => entitlement.months,
'days' => entitlement.days
)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/eligible_data_classes_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'bb/generate_report_request_form'
describe EligibleDataClassesSerializer, type: :serializer do
subject { serialize(eligible_data_classes, { serializer_class: described_class, is_collection: false }) }
let(:eligible_data_classes) { build_list(:eligible_data_class, 3) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['data']).to be_blank
end
it 'includes :type' do
expect(data['type']).to eq 'eligible_data_classes'
end
it 'includes :data_classes' do
expect(attributes['data_classes']).to eq eligible_data_classes.map(&:name)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/decision_review_evidence_attachment_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe DecisionReviewEvidenceAttachmentSerializer, type: :serializer do
subject { serialize(attachment, serializer_class: described_class) }
let(:attachment) { build_stubbed(:decision_review_evidence_attachment) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
let(:links) { data['links'] }
it 'includes :id' do
expect(data['id'].to_i).to eq attachment.id
end
it 'includes :guid' do
expect(attributes['guid']).to eq attachment.guid
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/hca_rating_info_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe HCARatingInfoSerializer, type: :serializer do
subject { serialize(rating_info, serializer_class: described_class) }
let(:rating_info) { { user_percent_of_disability: 1 } }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :user_percent_of_disability' do
expect(attributes['user_percent_of_disability']).to eq rating_info[:user_percent_of_disability]
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/saved_claim_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe SavedClaimSerializer, type: :serializer do
subject { serialize(saved_claim, serializer_class: described_class) }
let(:saved_claim) { build_stubbed(:fake_saved_claim) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq saved_claim.id.to_s
end
it 'includes :submitted_at' do
expect_time_eq(attributes['submitted_at'], saved_claim.submitted_at)
end
it 'includes :regional_office' do
expect(attributes['regional_office']).to eq saved_claim.regional_office
end
it 'includes :confirmation_number' do
expect(attributes['confirmation_number']).to eq saved_claim.confirmation_number
end
it 'includes :guid' do
expect(attributes['guid']).to eq saved_claim.guid
end
it 'includes :form' do
expect(attributes['form']).to eq saved_claim.form_id
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/education_stem_claim_status_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe EducationStemClaimStatusSerializer do
context 'with unprocessed claim' do
subject { serialize(education_benefits_claim, serializer_class: described_class) }
let(:education_benefits_claim) { create(:education_benefits_claim_10203, :with_stem) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes id' do
expect(data['id']).to eq(education_benefits_claim.id.to_s)
end
it 'includes automated_denial' do
expect(attributes['automated_denial']).to be(false)
end
it 'includes remaining_entitlement' do
expect(attributes['remaining_entitlement']).to be_nil
end
it 'includes submitted_at' do
expect(attributes['submitted_at']).not_to be_nil
end
it 'includes denied_at' do
expect(attributes['denied_at']).to be_nil
end
it 'includes is_enrolled_stem' do
expect(attributes['is_enrolled_stem']).to eq(education_benefits_claim.saved_claim.parsed_form['isEnrolledStem'])
end
it 'includes is_pursuing_teaching_cert' do
expect(attributes['is_pursuing_teaching_cert']).to eq(
education_benefits_claim.saved_claim.parsed_form['isPursuingTeachingCert']
)
end
it 'includes benefit_left' do
expect(attributes['benefit_left']).to eq(education_benefits_claim.saved_claim.parsed_form['benefitLeft'])
end
it 'does not include any extra attributes' do
expect(attributes.keys).to eq(%w[confirmation_number
is_enrolled_stem
is_pursuing_teaching_cert
benefit_left
remaining_entitlement
automated_denial
denied_at
submitted_at])
end
end
context 'with denied claim' do
subject { serialize(education_benefits_claim, serializer_class: described_class) }
let(:education_benefits_claim) { create(:education_benefits_claim_10203, :with_denied_stem) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes automated_denial' do
expect(attributes['automated_denial']).to be(true)
end
it 'includes remaining_entitlement' do
expect(attributes['remaining_entitlement']).to eq(181)
end
it 'includes denied_at' do
expect(attributes['denied_at']).not_to be_nil
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/payment_history_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe PaymentHistorySerializer, type: :serializer do
subject { serialize(payment_history, serializer_class: described_class) }
let(:payments) do
[{
pay_check_dt: '2017-12-29T00:00:00.000-06:00',
pay_check_amount: '$3,261.10',
pay_check_type: 'Compensation & Pension - Recurring',
payment_method: 'Direct Deposit',
bank_name: 'NAVY FEDERAL CREDIT UNION',
account_number: '***4567'
}]
end
let(:return_payments) do
[{
returned_check_issue_dt: '2012-12-15T00:00:00.000-06:00',
returned_check_cancel_dt: '2013-01-01T00:00:00.000-06:00',
returned_check_amount: '$50.00',
returned_check_number: '12345678',
returned_check_type: 'CH31 VR&E',
return_reason: 'Other Reason'
}]
end
let(:payment_history) { PaymentHistory.new(payments:, return_payments:) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :type' do
expect(data['type']).to eq 'payment_history'
end
it 'includes :payments' do
expect(attributes['payments'].size).to eq payment_history.payments.size
end
it 'includes :payments with attributes' do
expect(attributes['payments'].first).to eq payment_history.payments.first.deep_stringify_keys
end
it 'includes :return_payments' do
expect(attributes['return_payments'].size).to eq payment_history.return_payments.size
end
it 'includes :return_payments with attributes' do
expect(attributes['return_payments'].first).to eq payment_history.return_payments.first.deep_stringify_keys
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/preferred_name_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe PreferredNameSerializer, type: :serializer do
subject { serialize(preferred_name_response, serializer_class: described_class) }
let(:preferred_name_response) { build(:preferred_name_response) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
let(:links) { data['links'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :preferred_name' do
expect(attributes['preferred_name']).to match(preferred_name_response.preferred_name.attributes.deep_stringify_keys)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/persistent_attachment_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe PersistentAttachmentSerializer, type: :serializer do
subject { serialize(attachment, serializer_class: described_class) }
let(:attachment) do
create(:persistent_attachment, guid: 'abc-123-guid').tap do |att|
allow(att).to receive_messages(
original_filename: 'doctors-note.pdf',
size: 4567
)
end
end
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq attachment.id.to_s
end
it 'includes :confirmation_code' do
expect(attributes['confirmation_code']).to eq attachment.guid
end
it 'includes :name' do
expect(attributes['name']).to eq attachment.original_filename
end
it 'includes :size' do
expect(attributes['size']).to eq attachment.size
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/communication_groups_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe CommunicationGroupsSerializer, type: :serializer do
subject { serialize(communication_groups, serializer_class: described_class) }
let(:communication_groups) { { communication_groups: [communication_group] } }
let(:communication_group) { build_stubbed(:communication_item_group) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :type' do
expect(data['type']).to eq('hashes')
end
it 'includes :communication_groups' do
expect(attributes['communication_groups'].size).to eq communication_groups[:communication_groups].size
expect(attributes['communication_groups'].first['id']).to eq communication_groups[:communication_groups].first.id
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/maintenance_window_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe MaintenanceWindowSerializer, type: :serializer do
subject { serialize(maintenance_window, serializer_class: described_class) }
let(:maintenance_window) { build_stubbed(:maintenance_window) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq maintenance_window.id.to_s
end
it 'includes :external_service' do
expect(attributes['external_service']).to eq maintenance_window.external_service
end
it 'includes :start_time' do
expect_time_eq(attributes['start_time'], maintenance_window.start_time)
end
it 'includes :end_time' do
expect_time_eq(attributes['end_time'], maintenance_window.end_time)
end
it 'includes :description' do
expect(attributes['description']).to eq maintenance_window.description
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/hca_attachment_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'support/1010_forms/shared_examples/attachment_serializer'
describe HCAAttachmentSerializer, type: :serializer do
it_behaves_like '1010 forms attachment serializer' do
let(:resource_name) { 'hca_attachment' }
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/benefits_intake_submission_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe BenefitsIntakeSubmissionSerializer, type: :serializer do
subject { serialize(submission, serializer_class: described_class) }
let(:submission) { build_stubbed(:central_mail_submission) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq submission.id.to_s
end
it 'includes :appointments as an array' do
expect(attributes['state']).to eq submission.state
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/shared_examples_evss_claim_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.shared_examples 'shared_evss_claim' do
it 'expects object_data to be defined' do
expect(object_data).not_to be_nil
end
it 'includes :id' do
expect(data['id']).to eq evss_claim.evss_id.to_s
end
it 'includes :date_filed' do
expect(attributes['date_filed']).to eq Date.strptime(object_data['date'], '%m/%d/%Y').to_s
end
it 'includes :phase_change_date' do
expect(attributes['phase_change_date']).to eq Date.strptime(
object_data['claim_phase_dates']['phase_change_date'], '%m/%d/%Y'
).to_s
end
it 'includes :min_est_date' do
date = object_data['min_est_claim_date']
expected_date = date ? Date.strptime(date, '%m/%d/%Y').to_s : nil
expect(attributes['min_est_date']).to eq expected_date
end
it 'includes :max_est_date' do
date = object_data['max_est_claim_date']
expected_date = date ? Date.strptime(date, '%m/%d/%Y').to_s : nil
expect(attributes['max_est_date']).to eq expected_date
end
it 'includes :development_letter_sent' do
expected_sent = object_data['development_letter_sent']&.downcase == 'yes'
expect(attributes['development_letter_sent']).to eq expected_sent
end
it 'includes :decision_letter_sent' do
expected_sent = object_data['decision_notification_sent']&.downcase == 'yes'
expect(attributes['decision_letter_sent']).to eq expected_sent
end
context 'when yes/no attributes have invalid values' do
let(:bad_data) { { 'development_letter_sent' => 'Test' } }
let(:evss_claim) { build(:evss_claim, data: bad_data, list_data: bad_data) }
it 'logs an error message' do
message = "Expected key EVSS 'development_letter_sent' to be Yes/No. Got 'Test'."
expect(Rails.logger).to receive(:error).with(message)
serialize(evss_claim, serializer_class: described_class)
end
end
it 'includes :documents_needed' do
expected_attention_needed = object_data['attention_needed']&.downcase == 'yes'
expect(attributes['documents_needed']).to eq expected_attention_needed
end
it 'includes :open' do
expect(attributes['open']).to eq object_data['claim_complete_date'].blank?
end
it 'includes :requested_decision' do
expect(attributes['requested_decision']).to eq object_data['waiver5103_submitted']
end
it 'includes :claim_type' do
expect(attributes['claim_type']).to eq object_data['status_type']
end
it 'includes :ever_phase_back' do
expect(attributes['ever_phase_back']).to eq object_data['claim_phase_dates']['ever_phase_back']
end
it 'includes :current_phase_back' do
expect(attributes['current_phase_back']).to eq object_data['claim_phase_dates']['current_phase_back']
end
context 'when :updated_at is nil' do
it 'does not include :updated_at' do
expect(attributes).not_to have_key('updated_at')
end
end
context 'when :updated_at is present' do
let(:evss_claim) { build(:evss_claim, updated_at: Time.current) }
it 'includes :updated_at' do
expect_time_eq(attributes['updated_at'], evss_claim.updated_at)
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/direct_deposits_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe DirectDepositsSerializer, feature: :direct_deposit,
team_owner: :vfs_authenticated_experience_backend, type: :serializer do
subject { serialize(direct_deposit, serializer_class: described_class) }
let(:direct_deposit) { build(:direct_deposit, :with_payment_account) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :type' do
expect(data['type']).to eq('direct_deposits')
end
it 'includes :control_information' do
expect(attributes['control_information']).to eq direct_deposit[:control_information].deep_stringify_keys
end
it 'includes :payment_account' do
expect(attributes['payment_account']).to eq direct_deposit[:payment_account].deep_stringify_keys
end
it 'includes :veteran_status' do
expect(attributes['veteran_status']).to eq direct_deposit[:veteran_status]
end
it 'masks account number' do
masked_account_number = StringHelpers.mask_sensitive(direct_deposit[:payment_account][:account_number])
expect(attributes['payment_account']['account_number']).to eq masked_account_number
end
it 'masks routing number' do
masked_routing_number = StringHelpers.mask_sensitive(direct_deposit[:payment_account][:routing_number])
expect(attributes['payment_account']['routing_number']).to eq masked_routing_number
end
context 'when payment_account does not exist' do
let(:direct_deposit) { build(:direct_deposit) }
it 'includes :payment_account as nil' do
expect(attributes['payment_account']).to be_nil
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/backend_statuses_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'pagerduty/external_services/service'
describe BackendStatusesSerializer do
subject { serialize(pagerduty_response, serializer_class: described_class) }
let(:backend_status) { build_stubbed(:pagerduty_service) }
let(:pagerduty_response) do
PagerDuty::ExternalServices::Response.new(200,
{ statuses: [backend_status.to_h], reported_at: Time.current.iso8601 })
end
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :statuses' do
expect(attributes['statuses'].size).to eq pagerduty_response.statuses.size
expect(attributes['statuses'].first['service']).to eq backend_status.service
end
context 'when maintence_windows is present' do
subject { serialize(pagerduty_response, { serializer_class: described_class, params: { maintenance_windows: } }) }
let(:maintenance_windows) { [build_stubbed(:maintenance_window)] }
it 'includes :maintence_windows' do
expect(attributes['maintenance_windows'].size).to eq maintenance_windows.size
expect(attributes['maintenance_windows'].first['id']).to eq maintenance_windows.first.id
end
end
context 'when mainteance_windows is not present' do
it 'includes :maintence_windows as empty arrays' do
expect(attributes['maintenance_windows']).to eq []
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/serializers/supporting_evidence_attachment_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe SupportingEvidenceAttachmentSerializer, type: :serializer do
subject { serialize(attachment, serializer_class: described_class) }
let(:attachment) { build_stubbed(:supporting_evidence_attachment, :with_file_data) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to eq attachment.id.to_s
end
it 'includes :guid' do
expect(attributes['guid']).to eq attachment.guid
end
end
|
0
|
code_files/vets-api-private/spec/serializers
|
code_files/vets-api-private/spec/serializers/async_transaction/base_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe AsyncTransaction::BaseSerializer, type: :serializer do
subject { serialize(async_transaction, serializer_class: described_class) }
let(:async_transaction) { build_stubbed(:async_transaction) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :transaction_id' do
expect(attributes['transaction_id']).to eq async_transaction.transaction_id
end
it 'includes :transaction_status' do
expect(attributes['transaction_status']).to eq async_transaction.transaction_status
end
it 'includes :type' do
expect(attributes['type']).to eq async_transaction.type
end
it 'includes :metadata' do
expect(attributes['metadata']).to eq async_transaction.parsed_metadata
end
end
|
0
|
code_files/vets-api-private/spec/serializers
|
code_files/vets-api-private/spec/serializers/form1010cg/attachment_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
require 'support/1010_forms/shared_examples/attachment_serializer'
RSpec.describe Form1010cg::AttachmentSerializer do
it_behaves_like '1010 forms attachment serializer' do
let(:resource_name) { 'form1010cg_attachment' }
end
end
|
0
|
code_files/vets-api-private/spec/serializers
|
code_files/vets-api-private/spec/serializers/form1010cg/submission_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
describe Form1010cg::SubmissionSerializer do
subject { serialize(submission, serializer_class: described_class) }
let(:submission) { build(:form1010cg_submission, :with_claim) }
let(:data) { JSON.parse(subject)['data'] }
let(:attributes) { data['attributes'] }
it 'includes :id' do
expect(data['id']).to be_blank
end
it 'includes :confirmation_number' do
expect(attributes['confirmation_number']).to eq submission.carma_case_id
end
it 'includes :submitted_at' do
expect_time_eq(attributes['submitted_at'], submission.accepted_at)
end
end
|
0
|
code_files/vets-api-private/spec/serializers/lighthouse
|
code_files/vets-api-private/spec/serializers/lighthouse/facilities/facility_serializer_spec.rb
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Lighthouse::Facilities::FacilitySerializer, team: :facilities do
# subject { serialize(facility, serializer_class: described_class) }
subject { described_class.new(facility) }
let(:facility) { build(:lighthouse_facility) }
let(:data) { subject.serializable_hash.with_indifferent_access['data'] }
let(:attributes) { data['attributes'] }
it 'includes id' do
expect(data['id']).to eq('vha_648A4')
end
it 'includes name' do
expect(data['attributes']['name']).to eq('Portland VA Medical Center-Vancouver')
end
it 'includes facility_type' do
expect(data['attributes']['facilityType']).to eq('va_health_facility')
end
it 'includes classification' do
expect(data['attributes']['classification']).to eq('VA Medical Center (VAMC)')
end
it 'includes website' do
expect(data['attributes']['website']).to eq('https://www.portland.va.gov/locations/vancouver.asp')
end
it 'includes lat and long' do
expect(data['attributes']['lat']).to be_within(0.05).of(45.6394162600001)
expect(data['attributes']['long']).to be_within(0.05).of(-122.65528736)
end
it 'includes address' do
expected_address = {
'mailing' => {},
'physical' => {
'zip' => '98661-3753',
'city' => 'Vancouver',
'state' => 'WA',
'address1' => '1601 East 4th Plain Boulevard',
'address2' => nil,
'address3' => nil
}
}
expect(data['attributes']['address']).to eq(expected_address)
end
it 'includes phone' do
expected_phone = {
'fax' => '360-690-0864',
'main' => '360-759-1901',
'pharmacy' => '503-273-5183',
'afterHours' => '360-696-4061',
'patientAdvocate' => '503-273-5308',
'mentalHealthClinic' => '503-273-5187',
'enrollmentCoordinator' => '503-273-5069'
}
expect(data['attributes']['phone']).to eq(expected_phone)
end
it 'includes hours' do
expected_hours = {
'monday' => '730AM-430PM',
'tuesday' => '730AM-630PM',
'wednesday' => '730AM-430PM',
'thursday' => '730AM-430PM',
'friday' => '730AM-430PM',
'saturday' => 'Closed',
'sunday' => 'Closed'
}
expect(data['attributes']['hours']).to eq(expected_hours)
end
it 'includes mobile' do
expect(data['attributes']['mobile']).to be(false)
end
it 'includes active_status' do
expect(data['attributes']['activeStatus']).to eq('A')
end
it 'includes visn' do
expect(data['attributes']['visn']).to eq('20')
end
it 'includes feedback' do
expected_satisfaction = {
'health' => {
'primaryCareUrgent' => a_kind_of(Float),
'primaryCareRoutine' => a_kind_of(Float)
},
'effectiveDate' => a_kind_of(Date)
}
expect(data['attributes']['feedback']).to match(expected_satisfaction)
end
it 'includes wait times' do
expected_wait_times = {
'health' => [
{ 'service' => 'Audiology', 'new' => a_kind_of(Float), 'established' => a_kind_of(Float) },
{ 'service' => 'Dermatology', 'new' => a_kind_of(Float), 'established' => a_kind_of(Float) },
{ 'service' => 'MentalHealthCare', 'new' => a_kind_of(Float), 'established' => a_kind_of(Float) },
{ 'service' => 'Ophthalmology', 'new' => a_kind_of(Float), 'established' => a_kind_of(Float) },
{ 'service' => 'Optometry', 'new' => a_kind_of(Float), 'established' => a_kind_of(Float) },
{ 'service' => 'PrimaryCare', 'new' => a_kind_of(Float), 'established' => a_kind_of(Float) },
{ 'service' => 'SpecialtyCare', 'new' => a_kind_of(Float), 'established' => a_kind_of(Float) }
],
'effectiveDate' => a_kind_of(Date)
}
expect(data['attributes']['access']).to include(expected_wait_times)
end
it 'includes services' do
expected_services = {
'other' => [],
'health' => %w[
Audiology DentalServices Dermatology EmergencyCare MentalHealthCare
Nutrition Ophthalmology Optometry Podiatry PrimaryCare SpecialtyCare
]
}
expect(data['attributes']['services']).to eq(expected_services)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/mr_client_helpers.rb
|
# frozen_string_literal: true
require 'medical_records/client'
module MedicalRecords
module ClientHelpers
TOKEN = 'SESSION_TOKEN'
def authenticated_client
MedicalRecords::Client.new(session: { user_uuid: '12345',
user_id: 11_898_795,
patient_fhir_id: 2952,
expires_at: Time.current + (60 * 60),
token: TOKEN },
icn: '123ABC')
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/stub_debt_letters.rb
|
# frozen_string_literal: true
require 'debt_management_center/debt_letter_downloader'
def stub_debt_letters(method)
let!(:letter_downloader) do
letter_downloader = double
expect(DebtManagementCenter::DebtLetterDownloader).to receive(:new).and_return(letter_downloader)
letter_downloader
end
if method == :show
let(:document_id) { '{93631483-E9F9-44AA-BB55-3552376400D8}' }
let(:content) { File.read('spec/fixtures/files/error_message.txt') }
before do
expect(letter_downloader).to receive(:get_letter).with(document_id).and_return(content)
expect(letter_downloader).to receive(:file_name).with(document_id).and_return('filename.pdf')
end
else
let(:list_letters_res) { get_fixture('vbms/list_letters') }
before do
expect(letter_downloader).to receive(:list_letters).and_return(
list_letters_res
)
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/factory_bot.rb
|
# frozen_string_literal: true
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/sm_spec_helper.rb
|
# frozen_string_literal: true
require 'rspec/rails'
RSpec.configure do |config|
config.before do
allow(Flipper).to receive(:enabled?).and_call_original
allow(Flipper).to receive(:enabled?).with(:mhv_secure_messaging_cerner_pilot, instance_of(User)).and_return(false)
allow(Flipper).to receive(:enabled?).with(:mhv_secure_messaging_large_attachments).and_return(false)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/request_helper.rb
|
# frozen_string_literal: true
module RequestHelper
def options(*)
reset! unless integration_session
integration_session.__send__(:process, :options, *).tap do
copy_session_variables!
end
end
# Returns an array of errors from the passed JSON
#
# @param response [String] A response as a string of JSON
# @return [Array] An array of error messages from the passed response
#
def errors_for(response)
parsed_body = JSON.parse(response.body)
parsed_body['errors'].pluck('detail')
end
# Returns a JSON object with the contents of the response body 'data' attribute
#
# @param response [String] A response as a string of JSON
# @return [Hash] A hash of the response body data
#
def json_body_for(response)
JSON.parse(response.body)['data']
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/poa_stub.rb
|
# frozen_string_literal: true
def stub_poa_verification
veteran_user_stub = instance_double(Veteran::User)
allow(Veteran::User).to receive(:new).and_return(veteran_user_stub)
poa_stub = instance_double(PowerOfAttorney, code: 'A01')
allow(veteran_user_stub).to receive(:power_of_attorney).and_return(poa_stub)
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/url_service_helpers.rb
|
# frozen_string_literal: true
RSpec::Matchers.define :be_a_saml_url do |expected_url_partial|
match do |actual_url|
# Use the URI library to parse the string, returning false if this fails.
query_params = CGI.parse(URI.parse(actual_url).query)
relay_state_params = query_params['RelayState'].present? ? JSON.parse(query_params['RelayState']&.first) : nil
other_params = query_params.except('RelayState', 'SAMLRequest').transform_values(&:first)
values_match?(Regexp.new(Regexp.escape(expected_url_partial)), actual_url) &&
(relay_state_params.present? ? values_match?(relay_state_params, @relay_state_params) : true) &&
(other_params.present? ? values_match?(other_params, @other_params) : true)
rescue URI::InvalidURIError
false
end
chain :with_relay_state do |relay_state_params|
@relay_state_params = relay_state_params
end
chain :with_params do |other_params|
@other_params = other_params
end
diffable
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/matchers.rb
|
# frozen_string_literal: true
Dir[File.join(__dir__, 'matchers', '*.rb')].each { |file| require file }
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/shared_examples_for_mhv.rb
|
# frozen_string_literal: true
shared_examples 'for user account level' do |options|
it "with MHV account level #{options[:account_level]}" do
expect(response).not_to be_successful
expect(response).to have_http_status(:forbidden)
expect(JSON.parse(response.body)['errors'].first['detail']).to eq(options[:message])
end
end
shared_examples 'for non va patient user' do |options|
let(:va_patient) { false }
it "is #{options[:authorized] ? '' : 'NOT'} authorized" do
expect(response).not_to be_successful
expect(response).to have_http_status(:forbidden)
expect(JSON.parse(response.body)['errors'].first['detail']).to eq(options[:message])
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/financial_status_report_helpers.rb
|
# frozen_string_literal: true
require 'debt_management_center/models/financial_status_report'
module FinancialStatusReportHelpers
def set_filenet_id(opts)
pdf = DebtManagementCenter::FinancialStatusReport.find_or_build(opts[:user].uuid)
pdf.update(filenet_id: opts[:filenet_id], uuid: opts[:user].uuid)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/silence_stream.rb
|
# frozen_string_literal: true
def silence
original_stdout = $stdout.clone
original_stderr = $stderr.clone
$stderr.reopen File.new('/dev/null', 'w')
$stdout.reopen File.new('/dev/null', 'w')
yield
ensure
$stdout.reopen original_stdout
$stderr.reopen original_stderr
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/spool_helpers.rb
|
# frozen_string_literal: true
module SpoolHelpers
extend ActiveSupport::Concern
module ClassMethods
# rubocop:disable Metrics/MethodLength
def test_spool_file(form_type, test_name, disabled_features = [])
describe "#{form_type} #{test_name} spool test" do
subject do
described_class.new(education_benefits_claim)
end
let(:file_prefix) { "spec/fixtures/education_benefits_claims/#{form_type}/#{test_name}." }
let(:form_class) { "SavedClaim::EducationBenefits::VA#{form_type}".constantize }
let(:education_benefits_claim) do
form_class.create!(
form: File.read("#{file_prefix}json")
).education_benefits_claim
end
before do
allow(education_benefits_claim).to receive(:id).and_return(1)
education_benefits_claim.instance_variable_set(:@application, nil)
end
it 'generates the spool file correctly', run_at: '2017-01-17 03:00:00 -0500' do
disabled_features.each do |feature|
allow(Flipper).to receive(:enabled?).with(feature).and_return(false)
end
windows_linebreak = EducationForm::CreateDailySpoolFiles::WINDOWS_NOTEPAD_LINEBREAK
expected_text = File.read("#{file_prefix}spl").rstrip
expected_text.gsub!("\n", windows_linebreak) unless expected_text.include?(windows_linebreak)
expect(subject.text).to eq(expected_text)
end
end
end
# rubocop:enable Metrics/MethodLength
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/vcr_multipart_matcher_helper.rb
|
# frozen_string_literal: true
# This is needed for mismatching multi-part boundaries -- replacing random boundaries within the 'Content-Type' header
# Multipart boundaries are most often randomly generated by the HTTP library or browser
# so when VCR tries to match a multipart request with a cassette,
# the boundaries will be different and the match will fail.
# Thischange was introduced when upgrading to Faraday 0.17.0
# The Content-Type header makes the request recognizable as multipart request but also specifies the exact boundary
# example: The boundary is random/unique per request. Upon VCR cassette matching, the request boundary fails:
# before normalizing boundary: "Content-Type"=>[...=-----------RubyMultipartPost-59e4838b71b5b6d9da3596629c7aa4bc"]
# after normalizing boundary: "Content-Type"=>[...=-----------RubyMultipartPost"]
MULTIPART_HEADER_MATCHER = %r{^multipart/form-data; boundary=(.+)$}
BOUNDARY_STRING = '-----------RubyMultipartPost'
def normalized_multipart_request(request)
content_type = (request.headers['Content-Type'] || []).first.to_s
boundary = MULTIPART_HEADER_MATCHER.match(content_type)[1]
request.headers['Content-Type'].first.gsub!(boundary, BOUNDARY_STRING)
request.body.gsub!(boundary, BOUNDARY_STRING)
request.body.gsub!('RubyMultipartPost--\r\n"', 'RubyMultipartPost--\r\n\r\n"')
request.headers.delete('Content-Length')
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/excel_helpers.rb
|
# frozen_string_literal: true
module ExcelHelpers
extend ActiveSupport::Concern
module ClassMethods
# rubocop:disable Metrics/MethodLength
def test_excel_file(form_type, test_name, disabled_features = [])
describe "#{form_type} #{test_name} excel test" do
subject do
described_class.new(education_benefits_claim)
end
let(:file_prefix) { "spec/fixtures/education_benefits_claims/#{form_type}/#{test_name}." }
let(:form_class) { "SavedClaim::EducationBenefits::VA#{form_type}".constantize }
let(:education_benefits_claim) do
form_class.create!(
form: File.read("#{file_prefix}json")
).education_benefits_claim
end
before do
allow(education_benefits_claim).to receive(:id).and_return(1)
education_benefits_claim.instance_variable_set(:@application, nil)
end
it 'generates the excel data correctly', run_at: '2017-01-17 03:00:00 -0500' do
disabled_features.each do |feature|
allow(Flipper).to receive(:enabled?).with(feature).and_return(false)
end
expected_data = CSV.read("#{file_prefix}csv", headers: true)
# Format the application data using the form object
form = subject
row_data = EducationForm::CreateDailyExcelFiles::EXCEL_FIELDS.map do |field|
form.public_send(field)
end
# Create CSV data for comparison
generated_csv = CSV.generate do |csv|
csv << EducationForm::CreateDailyExcelFiles::HEADERS
csv << row_data
end
generated_data = CSV.parse(generated_csv, headers: true)
# Compare headers
expect(generated_data.headers).to eq(EducationForm::CreateDailyExcelFiles::HEADERS)
# Compare data row by row
expected_data.each_with_index do |expected_row, index|
generated_row = generated_data[index]
EducationForm::CreateDailyExcelFiles::EXCEL_FIELDS.each_with_index do |field, field_index|
expect(generated_row[field_index]).to eq(expected_row[field_index]),
"Mismatch in #{field} for row #{index + 1}. " \
"Expected: #{expected_row[field_index]}, " \
"Got: #{generated_row[field_index]}"
end
end
end
end
end
# rubocop:enable Metrics/MethodLength
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/default_configuration_helper.rb
|
# frozen_string_literal: true
require 'common/client/configuration/rest'
module Specs
module Common
module Client
class DefaultConfiguration < ::Common::Client::Configuration::REST
def connection
@conn ||= Faraday.new(base_path) do |faraday|
unless adapter_only
faraday.use(:breakers, service_name:)
faraday.use Faraday::Response::RaiseError
faraday.use :remove_cookies
end
faraday.adapter :httpclient
end
end
def service_name
'foo'
end
def adapter_only
false
end
def port
3010
end
def use_example_path
true
end
def base_path
use_example_path ? 'http://example.com' : "http://127.0.0.1:#{port}"
end
end
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/fake_api_key_for_lighthouse.txt
|
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDI5ZvwCiEOwGkO
IbMngl18RPOgiAJoew/TywJsCs3PafZRL+HLxg7hMKk4RcJzFkMwEysSFAKNaLzg
dHGiVj2CfK/vbYVq3r86A8uGbUSIjAxV4jdEs2f7so10OYbsewKeH/E6rn8jlHFv
Cg0JV9rsTvTYcYSkv/OAWStOcwm6Xpz7iAHUBe3yg9Dlv3Xc6kMU0KIyp+6NryQb
WKIu31nozoBe6zm5IOUZBq6HqzD7VUwcIk1CTWKJrNPzVxaQOCrgIOQC/qzyKXRY
HfThXy9W+goWHMES04oUtJT95Vg6VhGv1+amG9fjsDq3Kd/mfvX+jPuZE4LcnZpG
3OS28usJAgMBAAECggEBAJgwELx7/+T779nLv7tLb+SHG4Rd5G0f5LKOFMyiNp1M
6VNBkazb4kPHqDm/5vlmQQm3S6aLUA+t63+h1r+i0z/5kxIvBqYaDgU2AbfD6OoE
Jggdsb6ypjAvaCdGuSaGXUpKamUI8bmTZ4c1twB/9JGVkrgw7sobu6xcYIkybokm
b5VoiLellT1lTBpJW/bdOw5BnEePfu5bTiwnk0Ym3Xj639LDos6Hsb2Vm+hqdsBi
P3mlwgV4G8b1FjBD8/KAQuFzGQ0pXeYFxKwIRWHqgk0kJwhgXp5C75f3AvktvtjT
1kMSRQ7Segh82/Q3coiZ/fpPMXo7taBNuzgLVnvekgECgYEA/uWkUcuEkQFHds2/
XrFe4kQ4mLhoOMNJXoO9h29HnlZkd0r77yuPy5MJ0mGtGUk5bONYHJGRdpuYB/9/
nH9gfEvNiNlpIYM9/rkspu5lj7GZG/9aZRkrv/j4FEObc67FK0ob98ICq7NY0Z/u
hcOqFHH6c6syMCUM3sjB78YJQUkCgYEAycQmRDePpZnwsdEPspkzFM/j4TsdcXq1
kdMfVUZmqUCEteba5lz7Bry3TCp/UPvy1oipS0aO0TgwlXPhML1IKryeLEYfaT/d
OBM28yzAzyoBEQFeTe+syBkNuIw1EjEegTQUkjLygrlKeyswsfG4IZB271v9Mwk5
ucbUDwVmG8ECgYBbYWqKZGLvNT0wi0xrHz178qczoRDEIMbB2ors7ekIC8LSvZAa
S0yu19Tylk/fO9AZiFuDSnCSy+8yFtfh/AxUIzzZLdAx0oI8OpiWc+r3G91fGymG
CwMTPKd7ZE1rqKFJBrWGGgijE4/o/uQdEmt8DuyR4TMJ7Y5ypBha5G1W+QKBgHba
02fwCvCUhFNbQhIFaS/jXuv49Nk6XecvJRAIzsT5OrQk7+Iv97f6R0fY6PL92AlE
q+WqBMt+fDAt+QPLHM4AGnUeQbawZlJ4DzCktlfS+JnZ4oGqpG+jQo/qGAFFaiDW
Wx/cXzteh1+TC7ZnG/65qTZLTBZaYuTrGVRX69SBAoGBAJKMP53i9012oTMn3puv
iZafEWBm/fdcAJ2tSzL7TlASKu+k34JujzcfAYZV5RbCSz+eyV9gDN0h2Ujx5jLg
pl0IVj9tMtOXLvw/KSpNSj2uaLQWB82X2VZwtq6EkvTYD33DcZnF2Kv0pW7jcoSh
sk1G/ZGPI5ouMhkhE4+Nw+pj
-----END PRIVATE KEY-----
################################################################################
## This key is fake. To rerun the test cassettes please replace with your key ##
## You will also need to replace the client_id with an associated id ##
################################################################################
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/codeowners_parser.rb
|
# frozen_string_literal: true
class CodeownersParser
def perform(team_name)
parsed_codeowners = File.read('.github/CODEOWNERS').split("\n").map do |line|
next if line.start_with?('#')
next unless line.include?(team_name)
line.split.first
end
parsed_codeowners.compact
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/aws_helpers.rb
|
# frozen_string_literal: true
module AwsHelpers
def stub_reports_s3(filename)
url = 'http://foo'
s3 = double
uuid = 'foo'
bucket = double
obj = double
expect(Aws::S3::Resource).to receive(:new).once.with(
region: 'region',
access_key_id: 'key',
secret_access_key: 'secret'
).and_return(s3)
expect(SecureRandom).to receive(:uuid).once.and_return(uuid)
expect(s3).to receive(:bucket).once.with('bucket').and_return(bucket)
expect(bucket).to receive(:object).once.with("#{uuid}.csv").and_return(obj)
expect(obj).to receive(:upload_file).once.with(filename, content_type: 'text/csv')
expect(obj).to receive(:presigned_url).once.with(:get, expires_in: 1.week.to_i).and_return(url)
yield
url
end
def stub_maintenance_windows_s3(filename)
s3 = double
bucket = double
obj = double
expect(Aws::S3::Resource).to receive(:new).once.with(
region: 'region',
access_key_id: 'key',
secret_access_key: 'secret'
).and_return(s3)
expect(s3).to receive(:bucket).once.with('bucket').and_return(bucket)
expect(bucket).to receive(:object).once.with('maintenance_windows.json').and_return(obj)
expect(obj).to receive(:upload_file).once.with(filename, acl: 'public-read', content_type: 'application/json')
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/authenticated_session_helper.rb
|
# frozen_string_literal: true
module AuthenticatedSessionHelper
def sign_in(user = FactoryBot.build(:user, :loa3), token = nil, raw = false)
user = User.create(user) unless user.persisted?
token ||= 'abracadabra'
session_object = Session.create(uuid: user.uuid, token:)
session_options = { key: 'api_session', secure: false, http_only: true }
if raw
Rails::SessionCookie::App.new(session_object.to_hash, session_options).session_cookie
elsif cookies.is_a?(ActionDispatch::Cookies::CookieJar)
request.session = ActionController::TestSession.new(session_object.to_hash)
else
raw_session_cookie = Rails::SessionCookie::App.new(session_object.to_hash, session_options).session_cookie
cookies.merge(raw_session_cookie)
raw_session_cookie
end
end
def sign_in_as(user, token = nil)
sign_in(user, token)
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/vcr.rb
|
# frozen_string_literal: true
VCR.configure do |c|
c.cassette_library_dir = 'spec/support/vcr_cassettes'
c.hook_into :webmock
# experiencing VCR-induced frustation? uncomment this:
# c.debug_logger = File.open('vcr.log', 'w')
c.filter_sensitive_data('<APP_TOKEN>') { Settings.mhv.rx.app_token }
c.filter_sensitive_data('<AV_KEY>') { VAProfile::Configuration::SETTINGS.address_validation.api_key }
c.filter_sensitive_data('<BENEFITS_INTAKE_SERVICE_API_KEY>') { Settings.benefits_intake_service.api_key }
c.filter_sensitive_data('<CLAIMS_API_BD_URL>') { Settings.claims_api.benefits_documents.host }
c.filter_sensitive_data('<DMC_TOKEN>') { Settings.dmc.client_secret }
c.filter_sensitive_data('<DMC_BASE_URL>') { Settings.dmc.url }
c.filter_sensitive_data('<BGS_BASE_URL>') { Settings.bgs.url }
c.filter_sensitive_data('<EE_PASS>') { Settings.hca.ee.pass }
c.filter_sensitive_data('<EVSS_AWS_BASE_URL>') { Settings.evss.aws.url }
c.filter_sensitive_data('<EVSS_BASE_URL>') { Settings.evss.url }
c.filter_sensitive_data('<EVSS_DVP_BASE_URL>') { Settings.evss.dvp.url }
c.filter_sensitive_data('<FES_BASE_URL>') { Settings.claims_api.fes.host }
c.filter_sensitive_data('<FARADAY_VERSION>') { Faraday::Connection::USER_AGENT }
c.filter_sensitive_data('<DISABILITY_MAX_RATINGS_URI>') { Settings.disability_max_ratings_api.url }
c.filter_sensitive_data('<GIDS_URL>') { Settings.gids.url }
c.filter_sensitive_data('<LIGHTHOUSE_API_KEY>') { Settings.decision_review.api_key }
c.filter_sensitive_data('<LIGHTHOUSE_API_KEY>') { Settings.lighthouse.facilities.api_key }
c.filter_sensitive_data('<LIGHTHOUSE_BENEFITS_DISCOVERY_HOST>') { Settings.lighthouse.benefits_discovery.host }
c.filter_sensitive_data('<LIGHTHOUSE_CLAIMS_API_HOST>') { Settings.lighthouse.benefits_claims.host }
c.filter_sensitive_data('<LIGHTHOUSE_DIRECT_DEPOSIT_HOST>') { Settings.lighthouse.direct_deposit.host }
c.filter_sensitive_data('<LIGHTHOUSE_BRD_API_KEY>') { Settings.brd.api_key }
c.filter_sensitive_data('<LIGHTHOUSE_TV_API_KEY>') { Settings.claims_api.token_validation.api_key }
c.filter_sensitive_data('<LIGHTHOUSE_BASE_URL>') { Settings.lighthouse.benefits_documents.host }
c.filter_sensitive_data('<MDOT_KEY>') { Settings.mdot.api_key }
c.filter_sensitive_data('<MDOT_URL>') { Settings.mdot.url }
c.filter_sensitive_data('<MHV_HOST>') { Settings.mhv.rx.host }
c.filter_sensitive_data('<MHV_UHD_HOST>') { Settings.mhv.uhd.host }
c.filter_sensitive_data('<MHV_UHD_SECURITY_HOST>') { Settings.mhv.uhd.security_host }
c.filter_sensitive_data('<MHV_MR_HOST>') { Settings.mhv.medical_records.host }
c.filter_sensitive_data('<MHV_MR_X_AUTH_KEY>') { Settings.mhv.medical_records.x_auth_key }
c.filter_sensitive_data('<MHV_MR_APP_TOKEN>') { Settings.mhv.medical_records.app_token }
c.filter_sensitive_data('<MHV_X_API_KEY>') { Settings.mhv.medical_records.mhv_x_api_key }
c.filter_sensitive_data('<MHV_MR_X_API_KEY>') { Settings.mhv.medical_records.x_api_key }
c.filter_sensitive_data('<MHV_MR_X_API_KEY_V2>') { Settings.mhv.medical_records.x_api_key_v2 }
c.filter_sensitive_data('<MHV_SM_APP_TOKEN>') { Settings.mhv.sm.app_token }
c.filter_sensitive_data('<MHV_SM_HOST>') { Settings.mhv.api_gateway.hosts.sm_patient }
c.filter_sensitive_data('<MPI_URL>') { IdentitySettings.mvi.url }
c.filter_sensitive_data('<PD_TOKEN>') { Settings.maintenance.pagerduty_api_token }
c.filter_sensitive_data('<CENTRAL_MAIL_TOKEN>') { Settings.central_mail.upload.token }
c.filter_sensitive_data('<PPMS_API_KEY>') { Settings.ppms.api_keys }
c.filter_sensitive_data('<PRENEEDS_HOST>') { Settings.preneeds.host }
c.filter_sensitive_data('<VETS360_URL>') { Settings.vet360.url }
c.filter_sensitive_data('<MULESOFT_SECRET>') { Settings.form_10_10cg.carma.mulesoft.client_secret }
c.filter_sensitive_data('<SHAREPOINT_CLIENT_SECRET>') { Settings.vha.sharepoint.client_secret }
c.filter_sensitive_data('<TRAVEL_PAY_BASE_URL>') { Settings.travel_pay.base_url }
c.filter_sensitive_data('<ADDRESS_VALIDATION>') { VAProfile::Configuration::SETTINGS.address_validation.hostname }
c.filter_sensitive_data('<X_API_KEY>') { Settings.mhv.rx.x_api_key }
c.filter_sensitive_data('<LIGHTHOUSE_BENEFITS_EDUCATION_RSA_KEY_PATH>') do
Settings.lighthouse.benefits_education.rsa_key
end
c.filter_sensitive_data('<LIGHTHOUSE_BENEFITS_EDUCATION_CLIENT_ID>') do
Settings.lighthouse.benefits_education.client_id
end
c.filter_sensitive_data('<LIGHTHOUSE_BENEFITS_INTAKE_API_KEY>') do
Settings.lighthouse.benefits_intake.api_key
end
c.filter_sensitive_data('<LIGHTHOUSE_BENEFITS_INTAKE_URL>') do
BenefitsIntake::Service.configuration.service_path
end
c.filter_sensitive_data('<VEIS_AUTH_URL>') { Settings.travel_pay.veis.auth_url }
c.filter_sensitive_data('<CONTENTION_CLASSIFICATION_API_URL>') { Settings.contention_classification_api.url }
c.filter_sensitive_data('<VA_MOBILE_URL>') { Settings.va_mobile.url }
c.filter_sensitive_data('<VAOS_PATIENTS_PATH>') { Settings.va_mobile.patients_path }
c.filter_sensitive_data('<BENEFITS_CLAIMS_PATH>') { Settings.va_mobile.claims_path }
c.filter_sensitive_data('<ARP_ALLOW_LIST_ACCESS_TOKEN>') do
Settings.accredited_representative_portal.allow_list.github.access_token
end
c.filter_sensitive_data('<ARP_ALLOW_LIST_BASE_URI>') do
Settings.accredited_representative_portal.allow_list.github.base_uri
end
c.filter_sensitive_data('<ARP_ALLOW_LIST_REPO>') { Settings.accredited_representative_portal.allow_list.github.repo }
c.filter_sensitive_data('<ARP_ALLOW_LIST_PATH>') { Settings.accredited_representative_portal.allow_list.github.path }
c.filter_sensitive_data('<VAOS_CCRA_API_URL>') { Settings.vaos.ccra.api_url }
c.filter_sensitive_data('<VAOS_EPS_TOKEN_URL>') { Settings.vaos.eps.access_token_url }
c.filter_sensitive_data('<VAOS_EPS_API_URL>') { Settings.vaos.eps.api_url }
c.filter_sensitive_data('<VAOS_EPS_API_PATH>') { Settings.vaos.eps.base_path }
c.filter_sensitive_data('<TRAVEL_CLAIM_API_URL>') { TravelClaim::Configuration.instance.base_path }
c.filter_sensitive_data('<VETERAN_ENROLLMENT_SYSTEM_BASE_URI>') do
"#{Settings.veteran_enrollment_system.host}:#{Settings.veteran_enrollment_system.port}"
end
c.filter_sensitive_data('<VETERAN_ENROLLMENT_SYSTEM>') { Settings.hca.endpoint }
c.filter_sensitive_data('<CASEFLOW_API_HOST>') { Settings.caseflow.host }
c.filter_sensitive_data('<DGI_VETS_URL>') { Settings.dgi.vets.url }
c.filter_sensitive_data('<LIGHTHOUSE_HCC_HOST>') do
Settings.lighthouse.healthcare_cost_and_coverage.host
end
c.before_record do |i|
%i[response request].each do |env|
next unless i.send(env).headers.keys.include?('Token')
i.send(env).headers.update('Token' => '<SESSION_TOKEN>')
end
end
c.before_record do |i|
%i[response request].each do |env|
next unless i.send(env).headers.keys.include?('Authorization')
i.send(env).headers.update('Authorization' => 'Bearer <TOKEN>')
end
end
c.register_request_matcher :sm_user_ignoring_path_param do |request1, request2|
# Matches, ignoring the user id and icn after `/isValidSMUser/` to handle any user id and icn
# E.g. <HOST>mhvapi/v1/usermgmt/usereligibility/isValidSMUser/10000000/1000000000V000000
path1 = request1.uri.gsub(%r{/isValidSMUser/.*}, '/isValidSMUser')
path2 = request2.uri.gsub(%r{/isValidSMUser/.*}, '/isValidSMUser')
path1 == path2
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/bb_client_helpers.rb
|
# frozen_string_literal: true
require 'bb/client'
module BB
module ClientHelpers
TOKEN = 'GkuX2OZ4dCE=48xrH6ObGXZ45ZAg70LBahi7CjswZe8SZGKMUVFIU88='
def authenticated_client
BB::Client.new(session: { user_id: 123, expires_at: Time.current + (60 * 60), token: TOKEN })
end
end
end
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/sign_in.rb
|
# frozen_string_literal: true
require_relative 'sign_in/service_account_authorization_context'
require_relative 'sign_in/shared_contexts'
require_relative 'sign_in/shared_examples'
|
0
|
code_files/vets-api-private/spec
|
code_files/vets-api-private/spec/support/sm_client_helpers.rb
|
# frozen_string_literal: true
require 'sm/client'
module SM
module ClientHelpers
TOKEN = 'GkuX2OZ4dCE=48xrH6ObGXZ45ZAg70LBahi7CjswZe8SZGKMUVFIU88='
def authenticated_client
SM::Client.new(session: { user_id: 123,
expires_at: Time.current + (60 * 60),
token: TOKEN })
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.