From c93e33e736d436bec156e3c499719affc7302e3e Mon Sep 17 00:00:00 2001 From: Bruce Bolt Date: Thu, 16 Feb 2023 10:23:52 +0000 Subject: [PATCH] Show current exemption date when editing 2SV exemption 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. --- app/views/two_step_verification_exemptions/edit.html.erb | 2 +- test/integration/managing_two_step_verification_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/two_step_verification_exemptions/edit.html.erb b/app/views/two_step_verification_exemptions/edit.html.erb index ab51b986e..92f633c16 100644 --- a/app/views/two_step_verification_exemptions/edit.html.erb +++ b/app/views/two_step_verification_exemptions/edit.html.erb @@ -22,7 +22,7 @@
- <%= 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} %>

All exemptions must have an expiry date. As this date approaches, this exemption will need to be reviewed.

diff --git a/test/integration/managing_two_step_verification_test.rb b/test/integration/managing_two_step_verification_test.rb index 45ce8f882..b1ed2a07c 100644 --- a/test/integration/managing_two_step_verification_test.rb +++ b/test/integration/managing_two_step_verification_test.rb @@ -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)