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
30 changes: 28 additions & 2 deletions app/controllers/idv/cancellations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class CancellationsController < ApplicationController
before_action :confirm_idv_needed

def new
properties = ParseControllerFromReferer.new(request.referer).call
analytics.idv_cancellation_visited(step: params[:step], **properties)
self.session_go_back_path = go_back_path || idv_path
@hybrid_session = hybrid_session?
Expand All @@ -17,7 +16,10 @@ def new
end

def update
analytics.idv_cancellation_go_back(step: params[:step])
analytics.idv_cancellation_go_back(
step: params[:step],
**extra_analytics_attributes,
)
redirect_to session_go_back_path || idv_path
end

Expand All @@ -33,6 +35,30 @@ def destroy

private

def barcode_step?
params[:step] == 'barcode'
end

def enrollment
current_user.pending_in_person_enrollment
end

def extra_analytics_attributes
extra = {}
if barcode_step? && enrollment
extra.merge!(
cancelled_enrollment: false,
enrollment_code: enrollment.enrollment_code,
enrollment_id: enrollment.id,
)
end
extra
end

def properties
ParseControllerFromReferer.new(request.referer).call
end

def cancel_session
if hybrid_session?
cancel_document_capture_session
Expand Down
21 changes: 21 additions & 0 deletions app/controllers/idv/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ def destroy

private

def barcode_step?
params[:step] == 'barcode'
end

def enrollment
current_user.pending_in_person_enrollment
end

def extra_analytics_attributes
extra = {}
if barcode_step? && enrollment
extra.merge!(
cancelled_enrollment: true,
enrollment_code: enrollment.enrollment_code,
enrollment_id: enrollment.id,
)
end
extra
end

def location_params
params.permit(:step, :location).to_h.symbolize_keys
end
Expand Down Expand Up @@ -46,6 +66,7 @@ def log_analytics
analytics.idv_start_over(
step: location_params[:step],
location: location_params[:location],
**extra_analytics_attributes,
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/idv/in_person/ready_to_verify/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,5 @@
<% end %>

<%= render PageFooterComponent.new do %>
<%= link_to t('in_person_proofing.body.barcode.cancel_link_text'), idv_cancel_path(step: 'verify') %>
<%= link_to t('in_person_proofing.body.barcode.cancel_link_text'), idv_cancel_path(step: 'barcode') %>
<% end %>
18 changes: 17 additions & 1 deletion spec/controllers/idv/cancellations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@
end

describe '#update' do
let(:user) { create(:user) }
let(:enrollment) { create(:in_person_enrollment, :pending, user: user) }

before do
stub_sign_in
stub_sign_in(user)
stub_analytics
end

Expand All @@ -118,6 +121,19 @@
put :update, params: { step: 'first', cancel: 'true' }
end

it 'logs cancellation go back with extra analytics attributes for barcode step' do
expect(@analytics).to receive(:track_event).with(
'IdV: cancellation go back',
step: 'barcode',
proofing_components: nil,
cancelled_enrollment: false,
enrollment_code: enrollment.enrollment_code,
enrollment_id: enrollment.id,
)

put :update, params: { step: 'barcode', cancel: 'true' }
end

it 'redirects to idv_path' do
put :update, params: { cancel: 'true' }

Expand Down
16 changes: 15 additions & 1 deletion spec/controllers/idv/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe Idv::SessionsController do
let(:user) { build(:user) }
let(:enrollment) { create(:in_person_enrollment, :pending, user: user) }

before do
stub_sign_in(user)
Expand Down Expand Up @@ -45,7 +46,7 @@
end
end

it 'tracks the event in analytics' do
it 'tracks the idv_start_over event in analytics' do
delete :destroy, params: { step: 'first', location: 'get_help' }

expect(@analytics).to have_logged_event(
Expand All @@ -56,6 +57,19 @@
)
end

it 'logs idv_start_over event with extra analytics attributes for barcode step' do
expect(@analytics).to receive(:track_event).with(
'IdV: start over',
location: '',
proofing_components: nil,
step: 'barcode',
cancelled_enrollment: true,
enrollment_code: enrollment.enrollment_code,
enrollment_id: enrollment.id,
)
delete :destroy, params: { step: 'barcode', location: '' }
end

it 'redirect occurs to the start of identity verification' do
delete :destroy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

expect(rendered).to have_link(
t('in_person_proofing.body.barcode.cancel_link_text'),
href: idv_cancel_path(step: 'verify'),
href: idv_cancel_path(step: 'barcode'),
)
end

Expand Down