Translate subjects of enterprise emails

Minor text change

Fix #906

Thanks to Nicolas Blanc:
https://github.com/openfoodfoundation/openfoodnetwork/pull/937
This commit is contained in:
Maikel Linke
2016-05-06 11:13:15 +10:00
parent a11696b85e
commit 3e231da472
3 changed files with 20 additions and 8 deletions

View File

@@ -4,19 +4,26 @@ class EnterpriseMailer < Spree::BaseMailer
def welcome(enterprise)
@enterprise = enterprise
mail(:to => enterprise.email, :from => from_address,
:subject => "#{enterprise.name} is now on #{Spree::Config[:site_name]}")
subject = t('enterprise_mailer.welcome.subject',
enterprise: @enterprise.name,
sitename: Spree::Config[:site_name])
mail(:to => enterprise.email,
:from => from_address,
:subject => subject)
end
def confirmation_instructions(record, token, opts={})
def confirmation_instructions(record, token)
@token = token
find_enterprise(record)
mail(subject: "Please confirm your email for #{@enterprise.name}",
to: ( @enterprise.unconfirmed_email || @enterprise.email ),
from: from_address)
subject = t('enterprise_mailer.confirmation_instructions.subject',
enterprise: @enterprise.name)
mail(to: (@enterprise.unconfirmed_email || @enterprise.email),
from: from_address,
subject: subject)
end
private
def find_enterprise(enterprise)
@enterprise = enterprise.is_a?(Enterprise) ? enterprise : Enterprise.find(enterprise)
end

View File

@@ -32,6 +32,11 @@ en:
not_confirmed: Your email address could not be confirmed. Perhaps you have already completed this step?
confirmation_sent: "Confirmation email sent!"
confirmation_not_sent: "Could not send a confirmation email."
enterprise_mailer:
confirmation_instructions:
subject: "Please confirm the email address for %{enterprise}"
welcome:
subject: "%{enterprise} is now on %{sitename}"
home: "OFN"
title: Open Food Network
welcome_to: 'Welcome to '

View File

@@ -12,7 +12,7 @@ describe EnterpriseMailer do
EnterpriseMailer.confirmation_instructions(enterprise, 'token').deliver
ActionMailer::Base.deliveries.count.should == 1
mail = ActionMailer::Base.deliveries.first
expect(mail.subject).to eq "Please confirm your email for #{enterprise.name}"
expect(mail.subject).to eq "Please confirm the email address for #{enterprise.name}"
expect(mail.to).to include enterprise.email
expect(mail.reply_to).to be_nil
end
@@ -28,7 +28,7 @@ describe EnterpriseMailer do
EnterpriseMailer.confirmation_instructions(enterprise, 'token').deliver
ActionMailer::Base.deliveries.count.should == 1
mail = ActionMailer::Base.deliveries.first
expect(mail.subject).to eq "Please confirm your email for #{enterprise.name}"
expect(mail.subject).to eq "Please confirm the email address for #{enterprise.name}"
expect(mail.to).to include enterprise.unconfirmed_email
end
end