diff --git a/app/mailers/spree/base_mailer_decorator.rb b/app/mailers/spree/base_mailer_decorator.rb index f6cd835f84..863f97033a 100644 --- a/app/mailers/spree/base_mailer_decorator.rb +++ b/app/mailers/spree/base_mailer_decorator.rb @@ -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 diff --git a/spec/controllers/user_passwords_controller_spec.rb b/spec/controllers/user_passwords_controller_spec.rb index d6abe4619c..59a2f16280 100644 --- a/spec/controllers/user_passwords_controller_spec.rb +++ b/spec/controllers/user_passwords_controller_spec.rb @@ -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 diff --git a/spec/mailers/enterprise_mailer_spec.rb b/spec/mailers/enterprise_mailer_spec.rb index 7eda5ff505..bac747860f 100644 --- a/spec/mailers/enterprise_mailer_spec.rb +++ b/spec/mailers/enterprise_mailer_spec.rb @@ -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 diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index f1198ba39a..d8d9b58744 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -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