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
11 changes: 7 additions & 4 deletions app/controllers/idv/address_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def new
def update
form_result = idv_form.submit(profile_params)
analytics.track_event(Analytics::IDV_ADDRESS_SUBMITTED, form_result.to_h)
capture_address_edited(form_result)
if form_result.success?
success
else
Expand All @@ -28,10 +29,7 @@ def confirm_pii_from_doc
end

def idv_form
Idv::AddressForm.new(
user: current_user,
previous_params: idv_session.previous_profile_step_params,
)
Idv::AddressForm.new(@pii)
end

def success
Expand All @@ -48,5 +46,10 @@ def failure
def profile_params
params.require(:idv_form).permit(Idv::AddressForm::ATTRIBUTES)
end

def capture_address_edited(result)
address_edited = result.to_h[:address_edited]
user_session['idv/doc_auth']['address_edited'] = address_edited if address_edited
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel like sometimes we have a idv/capture_doc key in here for the hybrid flow? does this always exist?

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.

This is past the point where the hybrid flow rejoins the regular doc_auth flow so I assume so. I tried it out locally in the hybrid flow and it worked.

end
end
end
13 changes: 10 additions & 3 deletions app/forms/idv/address_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ def self.model_name
ActiveModel::Name.new(self, nil, 'Address')
end

def initialize(user)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting... this argument wasn't doing anything before?

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.

Nope and it wasn't even a user, but a hash with a user and previous_params, neither of which were ever accessed. ¯\_(ツ)_/¯

@user = user
def initialize(pii)
@pii = pii
@address_edited = false
end

def submit(params)
Expand All @@ -21,7 +22,10 @@ def submit(params)
FormResponse.new(
success: valid?,
errors: errors,
extra: { pii_like_keypaths: [[:errors, :zipcode ], [:error_details, :zipcode]] },
extra: {
address_edited: @address_edited,
pii_like_keypaths: [[:errors, :zipcode ], [:error_details, :zipcode]],
},
)
end

Expand All @@ -31,6 +35,9 @@ def consume_params(params)
params.each do |key, value|
raise_invalid_address_parameter_error(key) unless ATTRIBUTES.include?(key.to_sym)
send("#{key}=", value)
if send(key) != @pii[key] && (send(key).present? || @pii[key].present?)
@address_edited = true
end
end
end

Expand Down
5 changes: 4 additions & 1 deletion app/services/idv/steps/verify_wait_step_show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def async_state_done(current_async_state)
form_response = idv_result_to_form_response(
idv_result: current_async_state.result,
state: flow_session[:pii_from_doc][:state],
extra: { pii_like_keypaths: [[:errors, :ssn]] },
extra: {
address_edited: !!flow_session['address_edited'],
pii_like_keypaths: [[:errors, :ssn]],
},
)

if form_response.success?
Expand Down
21 changes: 21 additions & 0 deletions spec/features/idv/doc_auth/verify_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
end

it 'proceeds to the next page upon confirmation' do
allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics)

click_idv_continue

expect(page).to have_current_path(idv_phone_path)
Expand All @@ -35,6 +37,10 @@
expect(user.proofing_component.resolution_check).to eq('lexis_nexis')
expect(user.proofing_component.source_check).to eq('aamva')
expect(DocAuthLog.find_by(user_id: user.id).aamva).to eq(true)
expect(fake_analytics).to have_logged_event(
'IdV: doc auth optional verify_wait submitted',
address_edited: false,
)
end

it 'proceeds to address page prepopulated with defaults if the user clicks change address' do
Expand All @@ -46,6 +52,21 @@
expect(page).to have_selector("input[value='59010']")
end

it 'tracks when the user edits their address' do
allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics)

click_link t('doc_auth.buttons.change_address')
fill_out_address_form_ok
click_idv_continue # address form

click_idv_continue

expect(fake_analytics).to have_logged_event(
'IdV: doc auth optional verify_wait submitted',
address_edited: true,
)
end

it 'proceeds to the ssn page if the user clicks change ssn and allows user to go back' do
click_button t('doc_auth.buttons.change_ssn')

Expand Down