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
7 changes: 7 additions & 0 deletions app/forms/idv/in_person/address_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class AddressForm

attr_accessor(*ATTRIBUTES)

def initialize(capture_secondary_id_enabled:)
@capture_secondary_id_enabled = capture_secondary_id_enabled
end

def self.model_name
ActiveModel::Name.new(self, nil, 'InPersonAddress')
end
Expand All @@ -28,6 +32,9 @@ def submit(params)

private

attr_reader :capture_secondary_id_enabled
alias_method :capture_secondary_id_enabled?, :capture_secondary_id_enabled

def consume_params(params)
params.each do |key, value|
raise_invalid_address_parameter_error(key) unless ATTRIBUTES.include?(key.to_sym)
Expand Down
4 changes: 4 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ def idv_in_person_prepare_submitted(flow_path:, **extra)
track_event('IdV: in person proofing prepare submitted', flow_path: flow_path, **extra)
end

def idv_in_person_proofing_residential_address_submitted(**extra)
track_event('IdV: in person proofing residential address submitted', **extra)
end

def idv_in_person_proofing_address_submitted(**extra)
track_event('IdV: in person proofing address submitted', **extra)
end
Expand Down
2 changes: 2 additions & 0 deletions app/services/flow/base_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def url_options
@flow.controller.url_options
end

delegate :analytics_visited_event, :analytics_submitted_event, to: :class

private

def create_response(form_submit_response, call_response)
Expand Down
2 changes: 1 addition & 1 deletion app/services/flow/flow_state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def update

increment_step_name_counts
analytics.public_send(
flow.step_handler(step).analytics_submitted_event,
flow.step_handler_instance(step).analytics_submitted_event,
Copy link
Copy Markdown
Contributor

@svalexander svalexander Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably add a ticket to revisit this when the flow state machine is removed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. 👍🏻

**result.to_h.merge(analytics_properties),
)

Expand Down
17 changes: 14 additions & 3 deletions app/services/idv/steps/in_person/address_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@ def self.analytics_visited_event
:idv_in_person_proofing_address_visited
end

def self.analytics_submitted_event
:idv_in_person_proofing_address_submitted
def analytics_submitted_event
if capture_secondary_id_enabled?
:idv_in_person_proofing_residential_address_submitted
else
:idv_in_person_proofing_address_submitted
end
end

def call
Idv::InPerson::AddressForm::ATTRIBUTES.each do |attr|
next if attr == :same_address_as_id && capture_secondary_id_enabled?
flow_session[:pii_from_user][attr] = flow_params[attr]
end
end

def extra_view_variables
{
capture_secondary_id_enabled: capture_secondary_id_enabled?,
form:,
pii:,
updating_address:,
Expand All @@ -28,6 +34,10 @@ def extra_view_variables

private

def capture_secondary_id_enabled?
current_user.establishing_in_person_enrollment.capture_secondary_id_enabled
end

def updating_address
flow_session[:pii_from_user].has_key?(:address1)
end
Expand All @@ -45,7 +55,8 @@ def flow_params
end

def form
@form ||= Idv::InPerson::AddressForm.new
@form ||= Idv::InPerson::AddressForm.
new(capture_secondary_id_enabled: capture_secondary_id_enabled?)
end

def form_submit
Expand Down
4 changes: 2 additions & 2 deletions app/services/idv/steps/in_person/state_id_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def call

def extra_view_variables
{
capture_secondary_id_enabled:,
capture_secondary_id_enabled: capture_secondary_id_enabled?,
form:,
pii:,
parsed_dob:,
Expand All @@ -34,7 +34,7 @@ def extra_view_variables

private

def capture_secondary_id_enabled
def capture_secondary_id_enabled?
current_user.establishing_in_person_enrollment.capture_secondary_id_enabled
end

Expand Down
3 changes: 2 additions & 1 deletion app/validators/idv/in_person/form_address_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module FormAddressValidator

included do
validates :same_address_as_id,
presence: true
presence: true,
unless: :capture_secondary_id_enabled?

validates_with UspsInPersonProofing::TransliterableValidator,
fields: [:city],
Expand Down
87 changes: 53 additions & 34 deletions app/views/idv/in_person/address.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,35 @@
<%= render PageHeadingComponent.new.with_content(t('in_person_proofing.headings.address')) %>
<% end %>

<p>
<%= t('in_person_proofing.body.address.info') %>
<%= new_window_link_to(
t('in_person_proofing.body.address.learn_more'),
MarketingSite.help_center_article_url(
category: 'verify-your-identity',
article: 'verify-your-identity-in-person',
),
) %>
</p>
<% unless capture_secondary_id_enabled %>
<p>
<%= t('in_person_proofing.body.address.info') %>
<%= new_window_link_to(
t('in_person_proofing.body.address.learn_more'),
MarketingSite.help_center_article_url(
category: 'verify-your-identity',
article: 'verify-your-identity-in-person',
),
) %>
</p>
<% end %>

<%= simple_form_for(
form, url: url_for, method: 'PUT',
html: { autocomplete: 'off' }
) do |f| %>
<% if capture_secondary_id_enabled %>
<%= render ValidatedFieldComponent.new(
collection: us_states_territories,
form: f,
label: t('idv.form.state'),
label_html: { class: 'usa-label' },
name: :state,
prompt: t('in_person_proofing.form.address.state_prompt'),
required: true,
selected: pii[:state],
) %>
<% end %>
<%= render ValidatedFieldComponent.new(
form: f,
input_html: { value: pii[:address1] },
Expand All @@ -33,7 +47,7 @@
<%= render ValidatedFieldComponent.new(
form: f,
input_html: { value: pii[:address2] },
label: t('idv.form.address2_optional'),
label: capture_secondary_id_enabled ? t('idv.form.address2') : t('idv.form.address2_optional'),
label_html: { class: 'usa-label' },
maxlength: 255,
name: :address2,
Expand All @@ -48,16 +62,19 @@
name: :city,
required: true,
) %>
<%= render ValidatedFieldComponent.new(
collection: us_states_territories,
form: f,
label: t('idv.form.state'),
label_html: { class: 'usa-label' },
name: :state,
prompt: t('in_person_proofing.form.address.state_prompt'),
required: true,
selected: pii[:state],
) %>

<% unless capture_secondary_id_enabled %>
<%= render ValidatedFieldComponent.new(
collection: us_states_territories,
form: f,
label: t('idv.form.state'),
label_html: { class: 'usa-label' },
name: :state,
prompt: t('in_person_proofing.form.address.state_prompt'),
required: true,
selected: pii[:state],
) %>
<% end %>

<div class="tablet:grid-col-6">
<%# using :tel for mobile numeric keypad %>
Expand All @@ -74,19 +91,21 @@
) %>
</div>

<%= render ValidatedFieldComponent.new(
as: :radio_buttons,
checked: pii[:same_address_as_id],
collection: [
[t('in_person_proofing.form.address.same_address_choice_yes'), true],
[t('in_person_proofing.form.address.same_address_choice_no'), false],
],
form: f,
label: t('in_person_proofing.form.address.same_address'),
name: :same_address_as_id,
required: true,
wrapper: :uswds_radio_buttons,
) %>
<% unless capture_secondary_id_enabled %>
<%= render ValidatedFieldComponent.new(
as: :radio_buttons,
checked: pii[:same_address_as_id],
collection: [
[t('in_person_proofing.form.address.same_address_choice_yes'), true],
[t('in_person_proofing.form.address.same_address_choice_no'), false],
],
form: f,
label: t('in_person_proofing.form.address.same_address'),
name: :same_address_as_id,
required: true,
wrapper: :uswds_radio_buttons,
) %>
<% end %>

<%= f.submit class: 'margin-top-1' do %>
<% if updating_address %>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/in_person_proofing/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ en:
state_id_number_hint: May include letters and numbers
zipcode: ZIP Code
headings:
address: Enter your current address
address: Enter your current residential address
barcode: You’re ready to verify your identity in person with %{app_name}
cta: Having trouble verifying your ID online?
cta_variant: Try verifying your ID in person
Expand Down
2 changes: 1 addition & 1 deletion config/locales/in_person_proofing/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ es:
state_id_number_hint: Puede incluir letras y números
zipcode: Código postal
headings:
address: Ingrese su dirección actual
address: Ingresa tu domicilio actual
barcode: Está listo para verificar su identidad en persona con %{app_name}
cta: ¿Tiene problemas para verificar su documento de identidad en línea?
cta_variant: Intente verificar su ID en persona
Expand Down
2 changes: 1 addition & 1 deletion config/locales/in_person_proofing/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fr:
state_id_number_hint: Peut comprendre des lettres et des chiffres
zipcode: Code postal
headings:
address: Entrez votre adresse actuelle
address: Indiquez votre adresse résidentielle actuelle
barcode: Vous êtes prêt à vérifier votre identité en personne avec %{app_name}
cta: Vous avez des difficultés à vérifier votre identité en ligne?
cta_variant: Essayez de vérifier votre identité en personne
Expand Down
2 changes: 2 additions & 0 deletions spec/features/idv/analytics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@

before do
allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true)
allow(IdentityConfig.store).to receive(:in_person_capture_secondary_id_enabled).
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching this! 🙏🏻

and_return(false)
allow(AbTests::IN_PERSON_CTA).to receive(:bucket).and_return(:in_person_variant_a)
allow(IdentityConfig.store).to receive(:in_person_cta_variant_testing_enabled).
and_return(false)
Expand Down
9 changes: 8 additions & 1 deletion spec/features/idv/in_person_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,14 @@ def it_captures_address_with_state_id
# prepare page
complete_prepare_step(user)

complete_state_id_step(user, same_address_as_id: false, include_address: true)
complete_state_id_step(user, same_address_as_id: false, double_address_verification: true)

complete_address_step(user, double_address_verification: true)

# Ensure the page submitted successfully
expect(page).to have_content(
t('idv.form.ssn_label_html'),
)
end

context 'flag remains enabled' do
Expand Down
Loading