Skip to content

Commit

Permalink
Show current exemption date when editing 2SV exemption
Browse files Browse the repository at this point in the history
We were defaulting to showing tomorrow's date when editing a 2SV
exemption reason.

This meant an admin could unintentionally change the user's exemption
expiry date,

Changing this to show their current exemption by default.
  • Loading branch information
brucebolt committed Feb 16, 2023
1 parent 5c8deae commit c93e33e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/two_step_verification_exemptions/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="form-group add-top-margin">
<label for="user_expiry_date_for_2sv_exemption">Expiry date for exemption</label>
<div class="form-inline">
<%= date_select :user, :expiry_date_for_2sv_exemption, {start_year: Time.zone.today.year, selected: Time.zone.today + 1} %>
<%= date_select :user, :expiry_date_for_2sv_exemption, {start_year: Time.zone.today.year, default: Time.zone.today + 1, selected: @user.expiry_date_for_2sv_exemption} %>
</div>
</div>
<p>All exemptions must have an expiry date. As this date approaches, this exemption will need to be reviewed.</p>
Expand Down
6 changes: 6 additions & 0 deletions test/integration/managing_two_step_verification_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ class ManagingTwoStepVerificationTest < ActionDispatch::IntegrationTest

sign_in_as_and_edit_user(@super_admin, user_requiring_2sv)
click_link("Edit reason or expiry date for 2-step verification exemption")

assert page.has_field?("Reason for 2-step verification exemption", with: "user is exempt")
assert page.has_field?("user_expiry_date_for_2sv_exemption_1i", with: @expiry_date.year)
assert page.has_field?("user_expiry_date_for_2sv_exemption_2i", with: @expiry_date.month)
assert page.has_field?("user_expiry_date_for_2sv_exemption_3i", with: @expiry_date.day)

new_expiry_date = 1.month.from_now.to_date
fill_in_exemption_form(@reason_for_exemption, new_expiry_date)

Expand Down

0 comments on commit c93e33e

Please sign in to comment.