Skip to content

Commit

Permalink
API-24836-526-v2-sec-9-map-signature (#12834)
Browse files Browse the repository at this point in the history
* Adds test for signature in request spec.

* Rubocop
  • Loading branch information
stiehlrod authored Jun 5, 2023
1 parent 539837b commit b818965
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def submit
veteran_icn: target_veteran.mpi.icn
)
pdf_data = get_pdf_data
pdf_mapper_service(form_attributes, pdf_data).map_claim
pdf_mapper_service(form_attributes, pdf_data, target_veteran).map_claim

# evss_service.submit(auto_claim)

Expand All @@ -40,8 +40,8 @@ def attachments; end

private

def pdf_mapper_service(auto_claim, pdf_data)
ClaimsApi::V2::DisabilityCompensationPdfMapper.new(auto_claim, pdf_data)
def pdf_mapper_service(auto_claim, pdf_data, target_veteran)
ClaimsApi::V2::DisabilityCompensationPdfMapper.new(auto_claim, pdf_data, target_veteran)
end

def get_pdf_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
module ClaimsApi
module V2
class DisabilityCompensationPdfMapper
def initialize(auto_claim, pdf_data)
def initialize(auto_claim, pdf_data, target_veteran)
@auto_claim = auto_claim
@pdf_data = pdf_data
@target_veteran = target_veteran
end

def map_claim
Expand All @@ -25,21 +26,12 @@ def map_claim

def claim_attributes
@pdf_data[:data][:attributes] = @auto_claim&.deep_symbolize_keys
claim_date
claim_date_and_signature
veteran_info

@pdf_data
end

def claim_date
@pdf_data[:data][:attributes].merge!(claimCertificationAndSignature: {
dateSigned: @auto_claim&.dig('claimDate')
})
@pdf_data[:data][:attributes].delete(:claimDate)

@pdf_data
end

def homeless_attributes
@pdf_data[:data][:attributes][:homelessInformation] = @auto_claim&.dig('homeless')&.deep_symbolize_keys
@pdf_data[:data][:attributes].delete(:homeless)
Expand Down Expand Up @@ -298,6 +290,15 @@ def direct_deposit_information
@pdf_data
end

def claim_date_and_signature
name = "#{@target_veteran[:first_name]} #{@target_veteran[:last_name]}"
@pdf_data[:data][:attributes].merge!(claimCertificationAndSignature: {
dateSigned: @auto_claim&.dig('claimDate'),
signature: name
})
@pdf_data[:data][:attributes].delete(:claimDate)
end

def get_service_pay
@pdf_data[:data][:attributes].merge!(
servicePay: @auto_claim&.dig('servicePay')&.deep_symbolize_keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,38 @@
).read
)
end
let(:target_veteran) do
OpenStruct.new(
icn: '1013062086V794840',
first_name: 'abraham',
last_name: 'lincoln',
loa: { current: 3, highest: 3 },
ssn: '796111863',
edipi: '8040545646',
participant_id: '600061742',
mpi: OpenStruct.new(
icn: '1013062086V794840',
profile: OpenStruct.new(ssn: '796111863')
)
)
end

context '526 section 0, claim attributes' do
let(:form_attributes) { auto_claim.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data) }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the attributes correctly' do
mapper.map_claim

date_signed = pdf_data[:data][:attributes][:claimCertificationAndSignature][:dateSigned]
claim_process_type = pdf_data[:data][:attributes][:claimProcessType]

expect(date_signed).to eq('2023-02-18')
expect(claim_process_type).to eq('STANDARD_CLAIM_PROCESS')
end
end

context '526 section 1' do
let(:form_attributes) { auto_claim.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data) }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the mailing address' do
mapper.map_claim
Expand Down Expand Up @@ -105,7 +118,7 @@

context '526 section 2, change of address' do
let(:form_attributes) { auto_claim.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data) }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the dates' do
mapper.map_claim
Expand Down Expand Up @@ -135,7 +148,7 @@

context '526 section 3, homelessness' do
let(:form_attributes) { auto_claim.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data) }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the homeless_point_of_contact' do
mapper.map_claim
Expand All @@ -161,7 +174,7 @@

context '526 section 4, toxic exposure' do
let(:form_attributes) { auto_claim.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data) }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the attributes correctly' do
mapper.map_claim
Expand Down Expand Up @@ -210,7 +223,7 @@

context '526 section 5, claimInfo: diabilities' do
let(:form_attributes) { auto_claim.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data) }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the attributes correctly' do
mapper.map_claim
Expand Down Expand Up @@ -243,7 +256,7 @@

context '526 section 5, claim info: disabilities, & has conditions attribute' do
let(:form_attributes) { claim_without_exposure.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data) }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the has_condition related to exposure method correctly' do
mapper.map_claim
Expand All @@ -256,7 +269,7 @@

context '526 section 5, treatment centers' do
let(:form_attributes) { auto_claim.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data) }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the attributes correctly' do
mapper.map_claim
Expand All @@ -275,7 +288,7 @@

context '526 section 6, service info' do
let(:form_attributes) { auto_claim.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data) }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the attributes correctly' do
mapper.map_claim
Expand Down Expand Up @@ -341,7 +354,7 @@

context '526 section 7, service pay' do
let(:form_attributes) { auto_claim.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data) }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the attributes correctly' do
mapper.map_claim
Expand All @@ -359,7 +372,7 @@

context '526 section 8, direct deposot' do
let(:form_attributes) { auto_claim.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data) }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the attributes correctly' do
mapper.map_claim
Expand All @@ -379,5 +392,21 @@
expect(no_account).to eq(false)
end
end

context '526 section 9, date and signature' do
let(:form_attributes) { auto_claim.dig('data', 'attributes') || {} }
let(:mapper) { ClaimsApi::V2::DisabilityCompensationPdfMapper.new(form_attributes, pdf_data, target_veteran) }

it 'maps the attributes correctly' do
mapper.map_claim
@target_veteran = target_veteran

signature = pdf_data[:data][:attributes][:claimCertificationAndSignature][:signature]
date = pdf_data[:data][:attributes][:claimCertificationAndSignature][:dateSigned]

expect(date).to eq('2023-02-18')
expect(signature).to eq('abraham lincoln')
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,21 @@
end
end

context 'it gets the signature from the headers and MPI' do
it 'returns a 200, and gets the signature' do
with_okta_user(scopes) do |auth_header|
VCR.use_cassette('evss/claims/claims') do
VCR.use_cassette('brd/countries') do
VCR.use_cassette('brd/disabilities') do
post submit_path, params: data, headers: auth_header
expect(response).to have_http_status(:ok)
end
end
end
end
end
end

context 'when treatment startDate is in the wrong pattern' do
let(:treatment_start_date) { '12/01/1999' }

Expand Down

0 comments on commit b818965

Please sign in to comment.