diff --git a/app/services/proofing/aamva/applicant.rb b/app/services/proofing/aamva/applicant.rb index a0e697b0e8c..24dece1cb46 100644 --- a/app/services/proofing/aamva/applicant.rb +++ b/app/services/proofing/aamva/applicant.rb @@ -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 diff --git a/spec/services/proofing/aamva/applicant_spec.rb b/spec/services/proofing/aamva/applicant_spec.rb index cb53ffeed65..011d89e3174 100644 --- a/spec/services/proofing/aamva/applicant_spec.rb +++ b/spec/services/proofing/aamva/applicant_spec.rb @@ -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