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: 8 additions & 1 deletion app/forms/idv/doc_pii_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions config/locales/doc_auth/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions config/locales/doc_auth/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions config/locales/doc_auth/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions spec/controllers/idv/image_uploads_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -716,7 +718,7 @@
first_name: 'FAKEY',
last_name: 'MCFAKERSON',
date_of_birth: nil,
address: nil,
address: address1,
)

action
Expand Down
34 changes: 34 additions & 0 deletions spec/forms/idv/doc_pii_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -21,19 +22,22 @@
{ 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
{
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
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down