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
14 changes: 8 additions & 6 deletions app/controllers/idv/by_mail/enter_code_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ def index
# slightly different copy on this screen.
@user_did_not_receive_letter = !!params[:did_not_receive_letter]

gpo_mail = Idv::GpoMail.new(current_user)
@can_request_another_letter =
FeatureManagement.gpo_verification_enabled? &&
!gpo_mail.rate_limited? &&
!gpo_mail.profile_too_old?

analytics.idv_verify_by_mail_enter_code_visited(
source: if @user_did_not_receive_letter then 'gpo_reminder_email' end,
otp_rate_limited: rate_limiter.limited?,
user_can_request_another_letter: @can_request_another_letter,
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.

It feels to me like can_request_another_letter belongs as a method on Idv::GpoMail.

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.

Do we care why they can't request another letter? i.e. do we want to log the profile_too_old? and rate_limited? values?

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.

I think that we could, yeah here, yes. I'm about to do some work on this controller to address this AC on LG-11753

The error banner for "Incorrect verification code" now is prompted under the input field as "Incorrect verification code"

I'll incorporate this thought there

)

if rate_limiter.limited?
Expand All @@ -28,12 +36,6 @@ def index
@gpo_verify_form = GpoVerifyForm.new(user: current_user, pii: pii)
@code = session[:last_gpo_confirmation_code] if FeatureManagement.reveal_gpo_code?

gpo_mail = Idv::GpoMail.new(current_user)
@can_request_another_letter =
FeatureManagement.gpo_verification_enabled? &&
!gpo_mail.rate_limited? &&
!gpo_mail.profile_too_old?

if pii_locked?
redirect_to capture_password_url
else
Expand Down
16 changes: 16 additions & 0 deletions spec/controllers/idv/by_mail/enter_code_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
expect(@analytics).to have_logged_event(
'IdV: enter verify by mail code visited',
source: nil,
otp_rate_limited: false,
user_can_request_another_letter: true,
)
expect(response).to render_template('idv/by_mail/enter_code/index')
end
Expand Down Expand Up @@ -74,6 +76,8 @@
expect(@analytics).to have_logged_event(
'IdV: enter verify by mail code visited',
source: nil,
user_can_request_another_letter: true,
otp_rate_limited: true,
)
end
end
Expand All @@ -85,6 +89,16 @@
action
expect(assigns(:can_request_another_letter)).to eql(false)
end

it 'augments analytics event' do
action
expect(@analytics).to have_logged_event(
'IdV: enter verify by mail code visited',
source: nil,
user_can_request_another_letter: false,
otp_rate_limited: false,
)
end
end

context 'user clicked a "i did not receive my letter" link' do
Expand All @@ -100,6 +114,8 @@
expect(@analytics).to have_logged_event(
'IdV: enter verify by mail code visited',
source: 'gpo_reminder_email',
user_can_request_another_letter: true,
otp_rate_limited: false,
)
end
end
Expand Down