Skip to content

Commit

Permalink
Improve readability of UserMailer#unlock_time
Browse files Browse the repository at this point in the history
This matches the new content design.
  • Loading branch information
chrislo committed Sep 28, 2023
1 parent 9f98e3e commit b37a639
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ def locked_time
end

def unlock_time
(@user.locked_at + 1.hour).to_fs(:govuk_date)
t = (@user.locked_at + 1.hour)
time_part = t.to_fs(:govuk_time)
date_part = t.to_date.to_fs(:govuk_date)

"#{time_part} UK time on #{date_part}"
end

def account_name
Expand Down
4 changes: 2 additions & 2 deletions test/models/user_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def assert_support_present_in_text(link_text, email = @email)
setup do
GovukEnvironment.stubs(:production?).returns(false)
GovukEnvironment.stubs(:name).returns("test")
@the_time = Time.zone.now
@the_time = Time.zone.local(2023, 10, 31, 2, 0, 0)
user = User.new(name: "User", email: "user@example.com", locked_at: @the_time)
@email = UserMailer.unlock_instructions(user, "afaketoken")
end
Expand All @@ -167,7 +167,7 @@ def assert_support_present_in_text(link_text, email = @email)
end

should "state when the account will be unlocked" do
assert_body_includes "Your account will be unlocked at #{(@the_time + 1.hour).to_fs(:govuk_date)}"
assert_body_includes "Your account will be unlocked at 3:00am UK time on 31 October 2023"
end
end

Expand Down

0 comments on commit b37a639

Please sign in to comment.