Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create styled email for reset password instructions #13157

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/views/spree/user_mailer/reset_password_instructions.html.haml
Original file line number Diff line number Diff line change
@@ -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'
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 10 additions & 10 deletions spec/mailers/user_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -67,21 +67,21 @@
# 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.html_part.body).to include spree.edit_spree_user_password_url
end
end

Expand All @@ -90,12 +90,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
Expand Down
Loading