mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #13157 from drummer83/email_styled_password
Create styled email for reset password instructions
This commit is contained in:
@@ -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'
|
||||
@@ -4834,6 +4834,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.
|
||||
|
||||
@@ -35,15 +35,15 @@ RSpec.describe Spree::UserMailer do
|
||||
|
||||
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 @@ RSpec.describe Spree::UserMailer do
|
||||
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 @@ RSpec.describe Spree::UserMailer do
|
||||
# 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 @@ RSpec.describe Spree::UserMailer do
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user