Skip to content

Commit

Permalink
Merge pull request #2553 from alphagov/email-copy-updates
Browse files Browse the repository at this point in the history
Email copy updates
  • Loading branch information
chrislo authored Nov 28, 2023
2 parents 077d2c3 + 63ca273 commit a975a6f
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 33 deletions.
10 changes: 4 additions & 6 deletions app/views/user_mailer/invitation_instructions.text.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Someone has invited you to <%= t('department.name') %> Signon, you can accept it through the link below.
Your GOV.UK Signon account is ready.

<%= accept_invitation_url(@user, invitation_token: @token) %>
[Set your password to finish creating your account](<%= accept_invitation_url(@user, invitation_token: @token) %>) and get access to GOV.UK publishing apps.

If you don't want to accept the invitation, please ignore this email.
This link will expire in 2 weeks.

Your account won't be created until you access the link above and set your password.

If you do not access the link within two weeks, it will expire.
Ignore this email if you no longer need a Signon account to publish or view data about GOV.UK content.
10 changes: 4 additions & 6 deletions app/views/user_mailer/reset_password_instructions.text.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Someone has requested a link to change your password. You can do this through the link below.
Someone has asked to reset your Signon password.

<%= edit_password_url(@user, :reset_password_token => @token) %>
[Reset your password.](<%= edit_password_url(@user, :reset_password_token => @token) %>)

If you didn't request this, please ignore this email.
This link will expire in 6 hours. You can only use it once.

Your password won't change until you access the link above and create a new one.

The link will be valid for 6 hours and will only work once.
If you did not ask to reset your password, you can ignore this email.You can sign in using your current password.
2 changes: 1 addition & 1 deletion config/locales/devise.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ en:
confirmation_instructions:
subject: 'Confirm your email change'
reset_password_instructions:
subject: 'Reset password instructions'
subject: 'Reset password for GOV.UK publishing account'
unlock_instructions:
subject: 'Your %{app_name} account has been locked'
links:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/devise_invitable.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ en:
no_invitations_remaining: "No invitations remaining"
mailer:
invitation_instructions:
subject: 'Please confirm your account'
subject: 'Set up your GOV.UK publishing account'
2 changes: 1 addition & 1 deletion test/integration/batch_inviting_users_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def assert_user_created_and_invited(email, application, organisation: nil)
assert_equal "[email protected]", invite_email.from[0]
assert_nil invite_email.reply_to

assert_match "Please confirm your account", invite_email.subject
assert_match I18n.t("devise.mailer.invitation_instructions.subject"), invite_email.subject
end

def assert_user_not_created(email)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/email_change_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ class EmailChangeTest < ActionDispatch::IntegrationTest
user = User.invite!(name: "Jim", email: "[email protected]")

open_email("[email protected]")
assert_equal "Please confirm your account", current_email.subject
assert_equal I18n.t("devise.mailer.invitation_instructions.subject"), current_email.subject

visit new_user_session_path
signin_with(@admin)
admin_changes_email_address(user:, new_email: "[email protected]")

email = emails_sent_to("[email protected]").detect { |mail| mail.subject == "Please confirm your account" }
email = emails_sent_to("[email protected]").detect { |mail| mail.subject == I18n.t("devise.mailer.invitation_instructions.subject") }
assert email
assert email.body.include?("/users/invitation/accept?invitation_token=")
assert user.accept_invitation!
Expand Down
18 changes: 9 additions & 9 deletions test/integration/inviting_users_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class InvitingUsersTest < ActionDispatch::IntegrationTest
click_button "Create user and send email"

assert_equal "[email protected]", last_email.to[0]
assert_match "Please confirm your account", last_email.subject
assert_match I18n.t("devise.mailer.invitation_instructions.subject"), last_email.subject

assert has_field?("Mandate 2-step verification for this user")
check "Mandate 2-step verification for this user"
Expand All @@ -94,7 +94,7 @@ class InvitingUsersTest < ActionDispatch::IntegrationTest

assert_not_nil User.where(email: "[email protected]", role: "normal").last
assert_equal "[email protected]", last_email.to[0]
assert_match "Please confirm your account", last_email.subject
assert_match I18n.t("devise.mailer.invitation_instructions.subject"), last_email.subject
assert_equal false, User.where(email: "[email protected]", role: "normal").last.require_2sv?
end
end
Expand All @@ -114,7 +114,7 @@ class InvitingUsersTest < ActionDispatch::IntegrationTest

assert_not_nil User.where(email: "[email protected]", role: "normal").last
assert_equal "[email protected]", last_email.to[0]
assert_match "Please confirm your account", last_email.subject
assert_match I18n.t("devise.mailer.invitation_instructions.subject"), last_email.subject
assert User.where(email: "[email protected]", role: "normal").last.require_2sv?
end
end
Expand All @@ -136,7 +136,7 @@ class InvitingUsersTest < ActionDispatch::IntegrationTest
click_button "Resend signup email"

assert page.has_content?("Resent account signup email")
emails_received = all_emails.count { |email| email.subject == "Please confirm your account" }
emails_received = all_emails.count { |email| email.subject == I18n.t("devise.mailer.invitation_instructions.subject") }
assert_equal 2, emails_received
end
end
Expand Down Expand Up @@ -219,7 +219,7 @@ class InvitingUsersTest < ActionDispatch::IntegrationTest
click_button "Create user and send email"

assert_equal "[email protected]", last_email.to[0]
assert_match "Please confirm your account", last_email.subject
assert_match I18n.t("devise.mailer.invitation_instructions.subject"), last_email.subject

assert has_field?("Mandate 2-step verification for this user")
check "Mandate 2-step verification for this user"
Expand Down Expand Up @@ -252,7 +252,7 @@ class InvitingUsersTest < ActionDispatch::IntegrationTest

assert_not_nil User.where(email: "[email protected]", role: Roles::Superadmin.role_name).last
assert_equal "[email protected]", last_email.to[0]
assert_match "Please confirm your account", last_email.subject
assert_match I18n.t("devise.mailer.invitation_instructions.subject"), last_email.subject
assert User.where(email: "[email protected]", role: Roles::Superadmin.role_name).last.require_2sv?
end
end
Expand All @@ -268,7 +268,7 @@ class InvitingUsersTest < ActionDispatch::IntegrationTest

assert_not_nil User.where(email: "[email protected]", role: Roles::Admin.role_name).last
assert_equal "[email protected]", last_email.to[0]
assert_match "Please confirm your account", last_email.subject
assert_match I18n.t("devise.mailer.invitation_instructions.subject"), last_email.subject
assert User.where(email: "[email protected]", role: Roles::Admin.role_name).last.require_2sv?
end
end
Expand All @@ -290,7 +290,7 @@ class InvitingUsersTest < ActionDispatch::IntegrationTest

assert_not_nil User.where(email: "[email protected]", role: Roles::Superadmin.role_name).last
assert_equal "[email protected]", last_email.to[0]
assert_match "Please confirm your account", last_email.subject
assert_match I18n.t("devise.mailer.invitation_instructions.subject"), last_email.subject
assert User.where(email: "[email protected]", role: Roles::Superadmin.role_name).last.require_2sv?
end
end
Expand All @@ -306,7 +306,7 @@ class InvitingUsersTest < ActionDispatch::IntegrationTest

assert_not_nil User.where(email: "[email protected]", role: Roles::Admin.role_name).last
assert_equal "[email protected]", last_email.to[0]
assert_match "Please confirm your account", last_email.subject
assert_match I18n.t("devise.mailer.invitation_instructions.subject"), last_email.subject
assert User.where(email: "[email protected]", role: Roles::Admin.role_name).last.require_2sv?
end
end
Expand Down
10 changes: 5 additions & 5 deletions test/integration/password_reset_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PasswordResetTest < ActionDispatch::IntegrationTest

open_email(user.email)
assert current_email
assert_equal "Reset password instructions", current_email.subject
assert_equal I18n.t("devise.mailer.reset_password_instructions.subject"), current_email.subject

complete_password_reset(current_email, new_password:)
assert_response_contains("Your password was changed successfully")
Expand Down Expand Up @@ -67,7 +67,7 @@ class PasswordResetTest < ActionDispatch::IntegrationTest

open_email(user.email)
assert current_email
assert_equal "Reset password instructions", current_email.subject
assert_equal I18n.t("devise.mailer.reset_password_instructions.subject"), current_email.subject

complete_password_reset(current_email, new_password:)
assert_response_contains("Your password was changed successfully")
Expand All @@ -94,10 +94,10 @@ class PasswordResetTest < ActionDispatch::IntegrationTest

open_email(user.email)
assert current_email
assert_equal "Reset password instructions", current_email.subject
assert_equal I18n.t("devise.mailer.reset_password_instructions.subject"), current_email.subject

# simulate something following the link in the email.
current_email.find_link(href: false).click
visit_password_reset_url_in(current_email)

complete_password_reset(current_email, new_password:)
assert_response_contains("Your password was changed successfully")
Expand All @@ -111,7 +111,7 @@ class PasswordResetTest < ActionDispatch::IntegrationTest

open_email(user.email)

current_email.find_link(href: false).click
visit_password_reset_url_in(current_email)
fill_in "New password", with: "A Password"
fill_in "Confirm new password", with: "Not That Password"
click_button "Save password"
Expand Down
2 changes: 1 addition & 1 deletion test/models/batch_invitation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class BatchInvitationTest < ActiveSupport::TestCase

email = ActionMailer::Base.deliveries.last
assert_not_nil email
assert_equal "Please confirm your account", email.subject
assert_equal I18n.t("devise.mailer.invitation_instructions.subject"), email.subject
assert_equal ["[email protected]"], email.to
end
end
Expand Down
7 changes: 6 additions & 1 deletion test/support/password_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ def trigger_reset_for(email)
end

def complete_password_reset(email, options)
email.find_link(href: false).click
visit_password_reset_url_in(email)
fill_in "New password", with: options[:new_password]
fill_in "Confirm new password", with: options[:new_password]
click_button "Save password"
end

def visit_password_reset_url_in(email)
reset_password_url = /\[Reset your password\.\]\((?<url>http.*)\)/.match(email.body).named_captures["url"]
visit reset_password_url
end
end

0 comments on commit a975a6f

Please sign in to comment.