mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Reconfirmation email sends to the right address
This commit is contained in:
@@ -15,7 +15,7 @@ class EnterpriseMailer < Spree::BaseMailer
|
||||
find_enterprise(record)
|
||||
opts = {
|
||||
subject: "Please confirm your email for #{@enterprise.name}",
|
||||
to: @enterprise.email,
|
||||
to: ( @enterprise.unconfirmed_email || @enterprise.email ),
|
||||
from: from_address,
|
||||
}
|
||||
devise_mail(record, :confirmation_instructions, opts)
|
||||
|
||||
@@ -7,11 +7,29 @@ describe EnterpriseMailer do
|
||||
ActionMailer::Base.deliveries = []
|
||||
end
|
||||
|
||||
it "should send an email confirmation when given an enterprise" 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}"
|
||||
context "when given an enterprise without an unconfirmed_email" do
|
||||
it "should send an email confirmation to email" 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.to).to include enterprise.email
|
||||
end
|
||||
end
|
||||
|
||||
context "when given an enterprise with an unconfirmed_email" do
|
||||
before do
|
||||
enterprise.unconfirmed_email = "unconfirmed@email.com"
|
||||
enterprise.save!
|
||||
end
|
||||
|
||||
it "should send an email confirmation to unconfirmed_email" 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.to).to include enterprise.unconfirmed_email
|
||||
end
|
||||
end
|
||||
|
||||
it "should send a welcome email when given an enterprise" do
|
||||
|
||||
Reference in New Issue
Block a user