Reconfirmation email sends to the right address

This commit is contained in:
Rob Harrington
2014-11-12 12:30:32 +11:00
parent ee2ee5dba7
commit 6b21bbdf74
2 changed files with 24 additions and 6 deletions

View File

@@ -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)

View File

@@ -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