From 41f06bef59563cad535a339431a1b7f5623c6e44 Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Fri, 27 Mar 2015 00:00:31 +0200 Subject: [PATCH] Add link text to change password mail template Included a default fallback to provide a base English translation for users that are using a locale file that does not define this new key. --- app/views/clearance_mailer/change_password.html.erb | 9 ++++++--- config/locales/clearance.en.yml | 1 + spec/mailers/clearance_mailer_spec.rb | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/views/clearance_mailer/change_password.html.erb b/app/views/clearance_mailer/change_password.html.erb index ed01f74b5..bc315ecba 100644 --- a/app/views/clearance_mailer/change_password.html.erb +++ b/app/views/clearance_mailer/change_password.html.erb @@ -1,5 +1,8 @@ -<%= t(".opening") %> +

<%= t(".opening") %>

-<%= edit_user_password_url(@user, token: @user.confirmation_token.html_safe) %> +

+ <%= link_to t(".link_text", default: "Change my password"), + edit_user_password_url(@user, token: @user.confirmation_token.html_safe) %> +

-<%= raw t(".closing") %> +

<%= raw t(".closing") %>

diff --git a/config/locales/clearance.en.yml b/config/locales/clearance.en.yml index 89d160d3c..f246d468d 100644 --- a/config/locales/clearance.en.yml +++ b/config/locales/clearance.en.yml @@ -4,6 +4,7 @@ en: change_password: closing: If you didn't request this, ignore this email. Your password has not been changed. + link_text: Change my password opening: "Someone, hopefully you, requested we send you a link to change your password:" flashes: diff --git a/spec/mailers/clearance_mailer_spec.rb b/spec/mailers/clearance_mailer_spec.rb index 429478538..44d5d7b03 100644 --- a/spec/mailers/clearance_mailer_spec.rb +++ b/spec/mailers/clearance_mailer_spec.rb @@ -29,6 +29,9 @@ email = ClearanceMailer.change_password(user) expect(email.body.to_s).to include(link) + expect(email.body.to_s).to have_css( + "a", text: I18n.t("clearance_mailer.change_password.link_text") + ) end it "sets its subject" do