Skip to content

Commit

Permalink
API-23874 Track SC evidenceType on records (#11787)
Browse files Browse the repository at this point in the history
  • Loading branch information
cilestin authored Mar 2, 2023
1 parent 6b34bf0 commit 11a867d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def create
source: request_headers['X-Consumer-Username'].presence&.strip,
evidence_submission_indicated: evidence_submission_indicated?,
api_version: 'V2',
veteran_icn: request_headers['X-VA-ICN'].presence&.strip
veteran_icn: request_headers['X-VA-ICN'].presence&.strip,
metadata: { evidenceType: @json_body.dig(*%w[data attributes evidenceSubmission evidenceType]) }
)

render_model_errors(sc) and return unless sc.validate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ def new_base_path(path)
expect(parsed['data']['attributes']['status']).to eq('pending')
expect(parsed.dig('data', 'attributes', 'formData')).to be_a Hash
end

it 'stores the evidenceType(s) in metadata' do
post(path, params: data, headers: headers)
sc = AppealsApi::SupplementalClaim.find(parsed['data']['id'])
data_evidence_type = JSON.parse(data).dig(*%w[data attributes evidenceSubmission evidenceType])

expect(sc.metadata).to eq({ 'evidenceType' => data_evidence_type })
end
end

context 'when icn header is present' do
Expand Down Expand Up @@ -233,6 +241,7 @@ def new_base_path(path)
sc = AppealsApi::SupplementalClaim.find(sc_guid)

expect(sc.evidence_submission_indicated).to be_truthy
expect(sc.metadata['evidenceType']).to eq %w[upload]
end

it 'with no evidence' do
Expand All @@ -244,6 +253,7 @@ def new_base_path(path)
sc = AppealsApi::SupplementalClaim.find(sc_guid)

expect(sc.evidence_submission_indicated).to be_falsey
expect(sc.metadata['evidenceType']).to eq %w[none]
end

it 'evidenceType with both none and retrieval' do
Expand Down Expand Up @@ -282,6 +292,20 @@ def new_base_path(path)
sc = AppealsApi::SupplementalClaim.find(sc_guid)

expect(sc.evidence_submission_indicated).to be_falsey
expect(sc.metadata['evidenceType']).to eq %w[retrieval]
end

it 'with both retrieval and upload evidence' do
headers_with_nvc = JSON.parse(fixture_to_s('valid_200995_headers_extra.json', version: 'v2'))
mod_data = JSON.parse(fixture_to_s('valid_200995_extra.json', version: 'v2'))
mod_data['data']['attributes']['evidenceSubmission']['evidenceType'] = %w[retrieval upload]
post(path, params: mod_data.to_json, headers: headers_with_nvc)

sc_guid = JSON.parse(response.body)['data']['id']
sc = AppealsApi::SupplementalClaim.find(sc_guid)

expect(sc.evidence_submission_indicated).to be_truthy
expect(sc.metadata['evidenceType']).to match_array %w[retrieval upload]
end
end

Expand Down

0 comments on commit 11a867d

Please sign in to comment.