diff --git a/app/views/spree/user_mailer/reset_password_instructions.html.haml b/app/views/spree/user_mailer/reset_password_instructions.html.haml new file mode 100644 index 00000000000..69a2f26f065 --- /dev/null +++ b/app/views/spree/user_mailer/reset_password_instructions.html.haml @@ -0,0 +1,15 @@ +%h3 + = t('.dear_customer') +%p + = t('.request_sent_text') + +%p.callout + = t('.link_text') + %br + %strong + = link_to @edit_password_reset_url, @edit_password_reset_url + +%p + = t('.issue_text') + += render 'shared/mailers/signoff' diff --git a/config/locales/en.yml b/config/locales/en.yml index c899680a2a0..6a1bf09e237 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -4823,6 +4823,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using invoice_attached_text: Please find attached an invoice for your recent order from user_mailer: reset_password_instructions: + dear_customer: "Dear customer," request_sent_text: | A request to reset your password has been made. If you did not make this request, simply ignore this email. diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 14dbb566f34..9e9dc8e7adf 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -35,15 +35,15 @@ describe "#confirmation_instructions" do let(:token) { "random" } - subject(:email) { Spree::UserMailer.confirmation_instructions(user, token) } + subject(:mail) { Spree::UserMailer.confirmation_instructions(user, token) } it "sends an email" do - expect { email.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) + expect { mail.deliver_now }.to change { ActionMailer::Base.deliveries.count }.by(1) end context 'when the language is English' do it 'sends an email with the translated subject' do - email.deliver_now + mail.deliver_now expect(ActionMailer::Base.deliveries.first.subject).to include( "Please confirm your OFN account" @@ -55,7 +55,7 @@ let(:user) { build(:user, locale: 'es') } it 'sends an email with the translated subject' do - email.deliver_now + mail.deliver_now expect(ActionMailer::Base.deliveries.first.subject).to include( "Por favor, confirma tu cuenta de OFN" @@ -67,21 +67,22 @@ # adapted from https://github.com/spree/spree_auth_devise/blob/70737af/spec/mailers/user_mailer_spec.rb describe '#reset_password_instructions' do describe 'message contents' do - let(:message) { described_class.reset_password_instructions(user, nil).deliver_now } + subject(:mail) { described_class.reset_password_instructions(user, nil).deliver_now } context 'subject includes' do it 'translated devise instructions' do - expect(message.subject).to include "Reset password instructions" + expect(mail.subject).to include "Reset password instructions" end it 'Spree site name' do - expect(message.subject).to include Spree::Config[:site_name] + expect(mail.subject).to include Spree::Config[:site_name] end end context 'body includes' do it 'password reset url' do - expect(message.body.raw_source).to include spree.edit_spree_user_password_url + expect(mail.text_part.body).to include spree.edit_spree_user_password_url + expect(mail.html_part.body).to include spree.edit_spree_user_password_url end end @@ -90,12 +91,12 @@ it 'calls with_locale method with user selected locale' do expect(I18n).to receive(:with_locale).with('es') - message + mail end it 'calls devise reset_password_instructions subject' do expect(I18n).to receive(:t).with('spree.user_mailer.reset_password_instructions.subject') - message + mail end end end