Pick from_address from MailMethod as in Spree

Spree::Config[] picks it up from AppConfiguration rather than MailMethod
and so, gets a value different from the one configured.
This commit is contained in:
Pau Perez
2018-03-22 15:34:13 +01:00
parent 3c36d2d1a6
commit 2c588847df
4 changed files with 16 additions and 5 deletions

View File

@@ -7,8 +7,11 @@ Spree::BaseMailer.class_eval do
protected
# This method copies the one defined in Spree's mailers. It should be removed
# once in Spree v2.0 and Spree's BaseMailer class lands in our codebase.
# Then, we'll be able to rely on its #from_address.
def from_address
Spree::Config[:mails_from] || 'test@example.com'
Spree::MailMethod.current.preferred_mails_from
end
def roadie_options

View File

@@ -31,12 +31,16 @@ describe UserPasswordsController, type: :controller do
end
it "renders Darkswarm" do
Spree::MailMethod.create!(environment: 'test')
clear_jobs
user.send_reset_password_instructions
flush_jobs # Send the reset password instructions
user.reload
spree_get :edit, reset_password_token: user.reset_password_token
response.should render_template "user_passwords/edit"
expect(response).to render_template "user_passwords/edit"
end
describe "via ajax" do

View File

@@ -5,12 +5,14 @@ describe EnterpriseMailer do
before do
ActionMailer::Base.deliveries = []
Spree::MailMethod.create!(environment: 'test')
end
it "should send a welcome email when given an enterprise" do
it "sends a welcome email when given an enterprise" do
EnterpriseMailer.welcome(enterprise).deliver
ActionMailer::Base.deliveries.count.should == 1
mail = ActionMailer::Base.deliveries.first
expect(mail.subject).to eq "#{enterprise.name} is now on #{Spree::Config[:site_name]}"
expect(mail.subject)
.to eq "#{enterprise.name} is now on #{Spree::Config[:site_name]}"
end
end

View File

@@ -11,6 +11,8 @@ describe Spree::UserMailer do
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
Spree::MailMethod.create!(environment: 'test')
end
it "sends an email when given a user" do