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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app/services/proofing/aamva/applicant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ def self.from_proofer_applicant(applicant)
return if height.nil?

# From the AAMVA DLDV guide regarding formatting the height:
#
# The height is provided in feet-inches (i.e. 5 foot 10 inches is presented as "510").
#
[(height / 12).to_s, (height % 12).to_s].join('')
# > Height data should be 3 characters (i.e. 5 foot 7 inches is submitted as 507)
feet = (height / 12).floor
inches = (height % 12).floor

"#{feet}#{format('%02d', inches)}"
end
end.freeze
end
Expand Down
21 changes: 16 additions & 5 deletions spec/services/proofing/aamva/applicant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,22 @@
expect(aamva_applicant[:dob]).to eq('')
end

it 'should format the height' do
proofer_applicant[:height] = 73
aamva_applicant = Proofing::Aamva::Applicant.from_proofer_applicant(proofer_applicant)
context 'when height includes inches >= 10' do
it 'formats as expected' do
proofer_applicant[:height] = 95
aamva_applicant = Proofing::Aamva::Applicant.from_proofer_applicant(proofer_applicant)
expect(aamva_applicant[:height]).to eq('711')
end
end

# This is intended to describe 6'1"
expect(aamva_applicant[:height]).to eq('61')
context 'when height includes inches < 10' do
it 'formats as expected' do
proofer_applicant[:height] = 67
aamva_applicant = Proofing::Aamva::Applicant.from_proofer_applicant(proofer_applicant)

# From the DLDV user guide:
# > Height data should be 3 characters (i.e. 5 foot 7 inches is submitted as 507)
expect(aamva_applicant[:height]).to eq('507')
end
end
end