diff --git a/app/forms/idv/doc_pii_form.rb b/app/forms/idv/doc_pii_form.rb index ed8179fa2df..2c340884b65 100644 --- a/app/forms/idv/doc_pii_form.rb +++ b/app/forms/idv/doc_pii_form.rb @@ -4,7 +4,7 @@ class DocPiiForm validate :validate_pii - attr_reader :first_name, :last_name, :dob, :state, :zipcode, :attention_with_barcode, + attr_reader :first_name, :last_name, :dob, :address1, :state, :zipcode, :attention_with_barcode, :jurisdiction alias_method :attention_with_barcode?, :attention_with_barcode @@ -13,6 +13,7 @@ def initialize(pii:, attention_with_barcode: false) @first_name = pii[:first_name] @last_name = pii[:last_name] @dob = pii[:dob] + @address1 = pii[:address1] @state = pii[:state] @zipcode = pii[:zipcode] @jurisdiction = pii[:state_id_jurisdiction] @@ -45,6 +46,8 @@ def validate_pii errors.add(:pii, dob_error, type: :dob_error) elsif !dob_meets_min_age? errors.add(:pii, dob_min_age_error, type: :dob_min_age_error) + elsif address1.blank? + errors.add(:pii, address_error, type: :address_error) elsif !state_valid? errors.add(:pii, generic_error, type: :generic_error) elsif !zipcode_valid? @@ -101,5 +104,9 @@ def dob_error def dob_min_age_error I18n.t('doc_auth.errors.pii.birth_date_min_age') end + + def address_error + I18n.t('doc_auth.errors.alerts.address_check') + end end end diff --git a/config/locales/doc_auth/en.yml b/config/locales/doc_auth/en.yml index 9a0ed82f110..3385fe7c07c 100644 --- a/config/locales/doc_auth/en.yml +++ b/config/locales/doc_auth/en.yml @@ -15,6 +15,7 @@ en: upload_picture: Upload photo errors: alerts: + address_check: We couldn’t read the address on your ID. Try taking new pictures. barcode_content_check: We couldn’t read the barcode on the back of your ID. It could be because of a problem with the barcode, or the barcode is a new type that we don’t recognize yet. Use another state‑issued ID if diff --git a/config/locales/doc_auth/es.yml b/config/locales/doc_auth/es.yml index 37e96066ac6..1f1f3407c73 100644 --- a/config/locales/doc_auth/es.yml +++ b/config/locales/doc_auth/es.yml @@ -15,6 +15,8 @@ es: upload_picture: Subir foto errors: alerts: + address_check: No pudimos leer la dirección en su documento de identidad. + Intente de tomar nuevas fotos. barcode_content_check: No pudimos leer el código de barras en el reverso de su documento de identidad. Puede ser debido a un problema con el código de barras, o bien el código de barras es un nuevo tipo que aún no diff --git a/config/locales/doc_auth/fr.yml b/config/locales/doc_auth/fr.yml index 1a2c9ce03a2..47fb28b8d34 100644 --- a/config/locales/doc_auth/fr.yml +++ b/config/locales/doc_auth/fr.yml @@ -15,6 +15,8 @@ fr: upload_picture: Télécharger une photo errors: alerts: + address_check: Nous n’avons pas pu lire l’adresse sur votre pièce d’identité. + Essayez de prendre de nouvelles photos. barcode_content_check: Nous n’avons pas pu lire le code-barres au verso de votre carte d’identité. Cela pourrait être dû à un problème avec le code-barres, ou le code-barres est d’un type nouveau que nous ne diff --git a/spec/controllers/idv/image_uploads_controller_spec.rb b/spec/controllers/idv/image_uploads_controller_spec.rb index 1bf797ccf25..2bc98beffac 100644 --- a/spec/controllers/idv/image_uploads_controller_spec.rb +++ b/spec/controllers/idv/image_uploads_controller_spec.rb @@ -411,6 +411,7 @@ context 'but doc_pii validation fails' do let(:first_name) { 'FAKEY' } let(:last_name) { 'MCFAKERSON' } + let(:address1) { '123 Houston Ave' } let(:state) { 'ND' } let(:state_id_type) { 'drivers_license' } let(:dob) { '10/06/1938' } @@ -425,6 +426,7 @@ pii_from_doc: { first_name: first_name, last_name: last_name, + address1: address1, state: state, state_id_type: state_id_type, dob: dob, @@ -452,7 +454,7 @@ first_name: nil, last_name: 'MCFAKERSON', date_of_birth: '10/06/1938', - address: nil, + address: address1, document_back_image_filename: match(document_filename_regex), document_front_image_filename: match(document_filename_regex), document_image_encryption_key: match(base64_regex), @@ -539,7 +541,7 @@ first_name: nil, last_name: 'MCFAKERSON', date_of_birth: '10/06/1938', - address: nil, + address: address1, document_back_image_filename: nil, document_front_image_filename: nil, document_image_encryption_key: nil, @@ -626,7 +628,7 @@ first_name: 'FAKEY', last_name: 'MCFAKERSON', date_of_birth: '10/06/1938', - address: nil, + address: address1, document_back_image_filename: nil, document_front_image_filename: nil, document_image_encryption_key: nil, @@ -716,7 +718,7 @@ first_name: 'FAKEY', last_name: 'MCFAKERSON', date_of_birth: nil, - address: nil, + address: address1, ) action diff --git a/spec/forms/idv/doc_pii_form_spec.rb b/spec/forms/idv/doc_pii_form_spec.rb index b65d54bc72e..e44373e7af9 100644 --- a/spec/forms/idv/doc_pii_form_spec.rb +++ b/spec/forms/idv/doc_pii_form_spec.rb @@ -12,6 +12,7 @@ first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, dob: valid_dob, + address1: Faker::Address.street_address, zipcode: Faker::Address.zip_code, state: Faker::Address.state_abbr, state_id_jurisdiction: 'AL', @@ -21,12 +22,14 @@ { first_name: nil, last_name: nil, dob: valid_dob, + address1: Faker::Address.street_address, state: Faker::Address.state_abbr } end let(:name_and_dob_errors_pii) do { first_name: nil, last_name: nil, dob: nil, + address1: Faker::Address.street_address, state: Faker::Address.state_abbr } end let(:dob_min_age_error_pii) do @@ -34,6 +37,7 @@ first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, dob: too_young_dob, + address1: Faker::Address.street_address, state: Faker::Address.state_abbr, } end @@ -42,6 +46,7 @@ first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, dob: valid_dob, + address1: Faker::Address.street_address, state: Faker::Address.state_abbr, zipcode: 12345, state_id_jurisdiction: 'AL', @@ -52,6 +57,7 @@ first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, dob: valid_dob, + address1: Faker::Address.street_address, state: Faker::Address.state_abbr, zipcode: nil, state_id_jurisdiction: 'AL', @@ -62,11 +68,23 @@ first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, dob: valid_dob, + address1: Faker::Address.street_address, zipcode: Faker::Address.zip_code, state: Faker::Address.state_abbr, state_id_jurisdiction: 'XX', } end + let(:address1_error_pii) do + { + first_name: Faker::Name.first_name, + last_name: Faker::Name.last_name, + dob: valid_dob, + address1: nil, + zipcode: Faker::Address.zip_code, + state: Faker::Address.state_abbr, + state_id_jurisdiction: 'AL', + } + end let(:pii) { nil } describe '#submit' do @@ -183,6 +201,22 @@ expect(result.extra[:attention_with_barcode]).to eq(true) end end + + context 'when there is no address1 information' do + let(:subject) { Idv::DocPiiForm.new(pii: address1_error_pii) } + + it 'returns an error for not being able to read the address' do + result = subject.submit + + expect(result).to be_kind_of(FormResponse) + expect(result.success?).to eq(false) + expect(result.errors[:pii]).to eq [t('doc_auth.errors.alerts.address_check')] + expect(result.extra).to eq( + attention_with_barcode: false, + pii_like_keypaths: [[:pii]], + ) + end + end end context 'when there is an invalid jurisdiction' do