Replace deprecated ActionMailer#deliver with ActionMailer#deliver_now

DEPRECATION WARNING: `#deliver` is deprecated and will be removed in Rails 5. Use `#deliver_now` to deliver immediately or `#deliver_later` to deliver through Active Job.
This commit is contained in:
Matt-Yorkley
2021-01-08 13:39:09 +00:00
parent 27e83392bf
commit 3e6445c51c
33 changed files with 82 additions and 82 deletions

View File

@@ -15,7 +15,7 @@ module Spree
end
def testmail
if TestMailer.test_email(spree_current_user).deliver
if TestMailer.test_email(spree_current_user).deliver_now
flash[:success] = Spree.t('admin.mail_methods.testmail.delivery_success')
else
flash[:error] = Spree.t('admin.mail_methods.testmail.delivery_error')

View File

@@ -78,7 +78,7 @@ module Spree
end
def resend
Spree::OrderMailer.confirm_email_for_customer(@order.id, true).deliver
Spree::OrderMailer.confirm_email_for_customer(@order.id, true).deliver_now
flash[:success] = t('admin.orders.order_email_resent')
respond_with(@order) { |format| format.html { redirect_to :back } }
@@ -87,7 +87,7 @@ module Spree
def invoice
pdf = InvoiceRenderer.new.render_to_string(@order)
Spree::OrderMailer.invoice_email(@order.id, pdf).deliver
Spree::OrderMailer.invoice_email(@order.id, pdf).deliver_now
flash[:success] = t('admin.orders.invoice_email_sent')
respond_with(@order) { |format|

View File

@@ -2,7 +2,7 @@
class ConfirmOrderJob < ActiveJob::Base
def perform(order_id)
Spree::OrderMailer.confirm_email_for_customer(order_id).deliver
Spree::OrderMailer.confirm_email_for_shop(order_id).deliver
Spree::OrderMailer.confirm_email_for_customer(order_id).deliver_now
Spree::OrderMailer.confirm_email_for_shop(order_id).deliver_now
end
end

View File

@@ -3,6 +3,6 @@
class ConfirmSignupJob < ActiveJob::Base
def perform(user_id)
user = Spree::User.find user_id
Spree::UserMailer.signup_confirmation(user).deliver
Spree::UserMailer.signup_confirmation(user).deliver_now
end
end

View File

@@ -2,6 +2,6 @@ ManagerInvitationJob = Struct.new(:enterprise_id, :user_id) do
def perform
enterprise = Enterprise.find enterprise_id
user = Spree::User.find user_id
EnterpriseMailer.manager_invitation(enterprise, user).deliver
EnterpriseMailer.manager_invitation(enterprise, user).deliver_now
end
end

View File

@@ -5,7 +5,7 @@ class OrderCycleNotificationJob < ActiveJob::Base
def perform(order_cycle_id)
order_cycle = OrderCycle.find(order_cycle_id)
order_cycle.suppliers.each do |supplier|
ProducerMailer.order_cycle_report(supplier, order_cycle).deliver
ProducerMailer.order_cycle_report(supplier, order_cycle).deliver_now
end
end
end

View File

@@ -90,13 +90,13 @@ class SubscriptionConfirmJob
def send_confirmation_email(order)
order.update!
record_success(order)
SubscriptionMailer.confirmation_email(order).deliver
SubscriptionMailer.confirmation_email(order).deliver_now
end
def send_failed_payment_email(order, error_message = nil)
order.update!
record_and_log_error(:failed_payment, order, error_message)
SubscriptionMailer.failed_payment_email(order).deliver
SubscriptionMailer.failed_payment_email(order).deliver_now
rescue StandardError => e
Bugsnag.notify(e, order: order, error_message: error_message)
end

View File

@@ -87,11 +87,11 @@ class SubscriptionPlacementJob
def send_placement_email(order, changes)
record_issue(:changes, order) if changes.present?
record_success(order) if changes.blank?
SubscriptionMailer.placement_email(order, changes).deliver
SubscriptionMailer.placement_email(order, changes).deliver_now
end
def send_empty_email(order, changes)
record_issue(:empty, order)
SubscriptionMailer.empty_email(order, changes).deliver
SubscriptionMailer.empty_email(order, changes).deliver_now
end
end

View File

@@ -3,6 +3,6 @@
class WelcomeEnterpriseJob < ActiveJob::Base
def perform(enterprise_id)
enterprise = Enterprise.find enterprise_id
EnterpriseMailer.welcome(enterprise).deliver
EnterpriseMailer.welcome(enterprise).deliver_now
end
end

View File

@@ -824,7 +824,7 @@ module Spree
def after_cancel
shipments.each(&:cancel!)
OrderMailer.cancel_email(id).deliver
OrderMailer.cancel_email(id).deliver_now
self.payment_state = 'credit_owed' unless shipped?
end

View File

@@ -319,7 +319,7 @@ module Spree
end
def send_shipped_email
ShipmentMailer.shipped_email(id).deliver
ShipmentMailer.shipped_email(id).deliver_now
end
def update_adjustment_included_tax

View File

@@ -37,13 +37,13 @@ module OrderManagement
def send_placement_summary_emails
@summaries.values.each do |summary|
SubscriptionMailer.placement_summary_email(summary).deliver
SubscriptionMailer.placement_summary_email(summary).deliver_now
end
end
def send_confirmation_summary_emails
@summaries.values.each do |summary|
SubscriptionMailer.confirmation_summary_email(summary).deliver
SubscriptionMailer.confirmation_summary_email(summary).deliver_now
end
end

View File

@@ -100,7 +100,7 @@ module OrderManagement
let(:summary1) { double(:summary) }
let(:summary2) { double(:summary) }
let(:summaries) { { 1 => summary1, 2 => summary2 } }
let(:mail_mock) { double(:mail, deliver: true) }
let(:mail_mock) { double(:mail, deliver_now: true) }
before do
summarizer.instance_variable_set(:@summaries, summaries)
@@ -116,7 +116,7 @@ module OrderManagement
let(:summary1) { double(:summary) }
let(:summary2) { double(:summary) }
let(:summaries) { { 1 => summary1, 2 => summary2 } }
let(:mail_mock) { double(:mail, deliver: true) }
let(:mail_mock) { double(:mail, deliver_now: true) }
before do
summarizer.instance_variable_set(:@summaries, summaries)

View File

@@ -78,7 +78,7 @@ describe Admin::ProxyOrdersController, type: :controller do
before do
# Processing order to completion
allow(Spree::OrderMailer).to receive(:cancel_email) { double(:email, deliver: true) }
allow(Spree::OrderMailer).to receive(:cancel_email) { double(:email, deliver_now: true) }
OrderWorkflow.new(order).complete!
proxy_order.reload
proxy_order.cancel

View File

@@ -446,7 +446,7 @@ describe Admin::SubscriptionsController, type: :controller do
before do
params[:open_orders] = 'cancel'
allow(Spree::OrderMailer).to receive(:cancel_email) { mail_mock }
allow(mail_mock).to receive(:deliver)
allow(mail_mock).to receive(:deliver_now)
end
it 'renders the cancelled subscription as json, and cancels the open order' do
@@ -457,7 +457,7 @@ describe Admin::SubscriptionsController, type: :controller do
expect(subscription.reload.canceled_at).to be_within(5.seconds).of Time.zone.now
expect(order.reload.state).to eq 'canceled'
expect(proxy_order.reload.canceled_at).to be_within(5.seconds).of Time.zone.now
expect(mail_mock).to have_received(:deliver)
expect(mail_mock).to have_received(:deliver_now)
end
end
end
@@ -545,7 +545,7 @@ describe Admin::SubscriptionsController, type: :controller do
before do
params[:open_orders] = 'cancel'
allow(Spree::OrderMailer).to receive(:cancel_email) { mail_mock }
allow(mail_mock).to receive(:deliver)
allow(mail_mock).to receive(:deliver_now)
end
it 'renders the paused subscription as json, and cancels the open order' do
@@ -556,7 +556,7 @@ describe Admin::SubscriptionsController, type: :controller do
expect(subscription.reload.paused_at).to be_within(5.seconds).of Time.zone.now
expect(order.reload.state).to eq 'canceled'
expect(proxy_order.reload.canceled_at).to be_within(5.seconds).of Time.zone.now
expect(mail_mock).to have_received(:deliver)
expect(mail_mock).to have_received(:deliver_now)
end
end
end

View File

@@ -10,8 +10,8 @@ describe ConfirmOrderJob do
shop_confirm_fake = double(:confirm_email_for_shop)
expect(Spree::OrderMailer).to receive(:confirm_email_for_customer).and_return customer_confirm_fake
expect(Spree::OrderMailer).to receive(:confirm_email_for_shop).and_return shop_confirm_fake
expect(customer_confirm_fake).to receive :deliver
expect(shop_confirm_fake).to receive :deliver
expect(customer_confirm_fake).to receive :deliver_now
expect(shop_confirm_fake).to receive :deliver_now
ConfirmOrderJob.perform_now order.id
end

View File

@@ -8,7 +8,7 @@ describe ConfirmSignupJob do
it "sends a confirmation email to the user" do
mail = double(:mail)
expect(Spree::UserMailer).to receive(:signup_confirmation).with(user).and_return(mail)
expect(mail).to receive(:deliver)
expect(mail).to receive(:deliver_now)
ConfirmSignupJob.perform_now(user.id)
end

View File

@@ -4,7 +4,7 @@ require 'spec_helper'
describe OrderCycleNotificationJob do
let(:order_cycle) { create(:order_cycle) }
let(:mail) { double(:mail, deliver: true) }
let(:mail) { double(:mail, deliver_now: true) }
before do
allow(ProducerMailer).to receive(:order_cycle_report).twice.and_return(mail)

View File

@@ -240,7 +240,7 @@ describe SubscriptionConfirmJob do
describe "#send_confirmation_email" do
let(:order) { instance_double(Spree::Order) }
let(:mail_mock) { double(:mailer_mock, deliver: true) }
let(:mail_mock) { double(:mailer_mock, deliver_now: true) }
before do
allow(SubscriptionMailer).to receive(:confirmation_email) { mail_mock }
@@ -251,13 +251,13 @@ describe SubscriptionConfirmJob do
expect(job).to receive(:record_success).with(order).once
job.send(:send_confirmation_email, order)
expect(SubscriptionMailer).to have_received(:confirmation_email).with(order)
expect(mail_mock).to have_received(:deliver)
expect(mail_mock).to have_received(:deliver_now)
end
end
describe "#send_failed_payment_email" do
let(:order) { instance_double(Spree::Order) }
let(:mail_mock) { double(:mailer_mock, deliver: true) }
let(:mail_mock) { double(:mailer_mock, deliver_now: true) }
before do
allow(SubscriptionMailer).to receive(:failed_payment_email) { mail_mock }
@@ -268,7 +268,7 @@ describe SubscriptionConfirmJob do
expect(job).to receive(:record_and_log_error).with(:failed_payment, order, nil).once
job.send(:send_failed_payment_email, order)
expect(SubscriptionMailer).to have_received(:failed_payment_email).with(order)
expect(mail_mock).to have_received(:deliver)
expect(mail_mock).to have_received(:deliver_now)
end
end
end

View File

@@ -209,7 +209,7 @@ describe SubscriptionPlacementJob do
describe "#send_placement_email" do
let!(:order) { double(:order) }
let(:mail_mock) { double(:mailer_mock, deliver: true) }
let(:mail_mock) { double(:mailer_mock, deliver_now: true) }
before do
allow(SubscriptionMailer).to receive(:placement_email) { mail_mock }
@@ -222,7 +222,7 @@ describe SubscriptionPlacementJob do
expect(job).to receive(:record_issue).with(:changes, order).once
job.send(:send_placement_email, order, changes)
expect(SubscriptionMailer).to have_received(:placement_email).with(order, changes)
expect(mail_mock).to have_received(:deliver)
expect(mail_mock).to have_received(:deliver_now)
end
end
@@ -233,7 +233,7 @@ describe SubscriptionPlacementJob do
expect(job).to receive(:record_success).with(order).once
job.send(:send_placement_email, order, changes)
expect(SubscriptionMailer).to have_received(:placement_email)
expect(mail_mock).to have_received(:deliver)
expect(mail_mock).to have_received(:deliver_now)
end
end
end
@@ -241,7 +241,7 @@ describe SubscriptionPlacementJob do
describe "#send_empty_email" do
let!(:order) { double(:order) }
let(:changes) { double(:changes) }
let(:mail_mock) { double(:mailer_mock, deliver: true) }
let(:mail_mock) { double(:mailer_mock, deliver_now: true) }
before do
allow(SubscriptionMailer).to receive(:empty_email) { mail_mock }
@@ -251,7 +251,7 @@ describe SubscriptionPlacementJob do
expect(job).to receive(:record_issue).with(:empty, order).once
job.send(:send_empty_email, order, changes)
expect(SubscriptionMailer).to have_received(:empty_email).with(order, changes)
expect(mail_mock).to have_received(:deliver)
expect(mail_mock).to have_received(:deliver_now)
end
end
end

View File

@@ -8,7 +8,7 @@ describe WelcomeEnterpriseJob do
it "sends a welcome email to the enterprise" do
mail = double(:mail)
expect(EnterpriseMailer).to receive(:welcome).with(enterprise).and_return(mail)
expect(mail).to receive(:deliver)
expect(mail).to receive(:deliver_now)
WelcomeEnterpriseJob.perform_now(enterprise.id)
end

View File

@@ -24,7 +24,7 @@ describe Spree::OrderMailer do
it "should use the from address specified in the preference" do
Spree::Config[:mails_from] = "no-reply@foobar.com"
message.deliver
message.deliver_now
@email = ActionMailer::Base.deliveries.first
expect(@email.from).to eq ["no-reply@foobar.com"]
end
@@ -33,7 +33,7 @@ describe Spree::OrderMailer do
Spree::Config[:mails_from] = "preference@foobar.com"
message.from = "override@foobar.com"
message.to = "test@test.com"
message.deliver
message.deliver_now
email = ActionMailer::Base.deliveries.first
expect(email.from).to eq ["override@foobar.com"]
expect(email.to).to eq ["test@test.com"]
@@ -41,7 +41,7 @@ describe Spree::OrderMailer do
it "should add the bcc email when provided" do
Spree::Config[:mail_bcc] = "bcc-foo@foobar.com"
message.deliver
message.deliver_now
@email = ActionMailer::Base.deliveries.first
expect(@email.bcc).to eq ["bcc-foo@foobar.com"]
end
@@ -57,14 +57,14 @@ describe Spree::OrderMailer do
it "should replace the receipient with the specified address" do
Spree::Config[:intercept_email] = "intercept@foobar.com"
message.deliver
message.deliver_now
@email = ActionMailer::Base.deliveries.first
expect(@email.to).to eq ["intercept@foobar.com"]
end
it "should modify the subject to include the original email" do
Spree::Config[:intercept_email] = "intercept@foobar.com"
message.deliver
message.deliver_now
@email = ActionMailer::Base.deliveries.first
expect(@email.subject).to include order.distributor.contact.email
end
@@ -73,7 +73,7 @@ describe Spree::OrderMailer do
context "when intercept_mode is not provided" do
it "should not modify the recipient" do
Spree::Config[:intercept_email] = ""
message.deliver
message.deliver_now
@email = ActionMailer::Base.deliveries.first
expect(@email.to).to eq [order.distributor.contact.email]
end

View File

@@ -15,7 +15,7 @@ describe EnterpriseMailer do
describe "#welcome" do
it "sends a welcome email when given an enterprise" do
EnterpriseMailer.welcome(enterprise).deliver
EnterpriseMailer.welcome(enterprise).deliver_now
mail = ActionMailer::Base.deliveries.first
expect(mail.subject)
@@ -25,7 +25,7 @@ describe EnterpriseMailer do
describe "#manager_invitation" do
it "should send a manager invitation email when given an enterprise and user" do
EnterpriseMailer.manager_invitation(enterprise, user).deliver
EnterpriseMailer.manager_invitation(enterprise, user).deliver_now
expect(ActionMailer::Base.deliveries.count).to eq 1
mail = ActionMailer::Base.deliveries.first
expect(mail.subject).to eq "#{enterprise.name} has invited you to be a manager"

View File

@@ -23,14 +23,14 @@ describe Spree::OrderMailer do
it "confirm_email_for_customer accepts an order id as an alternative to an Order object" do
expect(Spree::Order).to receive(:find).with(order.id).and_return(order)
expect {
Spree::OrderMailer.confirm_email_for_customer(order.id).deliver
Spree::OrderMailer.confirm_email_for_customer(order.id).deliver_now
}.to_not raise_error
end
it "cancel_email accepts an order id as an alternative to an Order object" do
expect(Spree::Order).to receive(:find).with(order.id).and_return(order)
expect {
Spree::OrderMailer.cancel_email(order.id).deliver
Spree::OrderMailer.cancel_email(order.id).deliver_now
}.to_not raise_error
end
end
@@ -101,7 +101,7 @@ describe Spree::OrderMailer do
describe "for customers" do
it "should send an email to the customer when given an order" do
Spree::OrderMailer.confirm_email_for_customer(order.id).deliver
Spree::OrderMailer.confirm_email_for_customer(order.id).deliver_now
expect(ActionMailer::Base.deliveries.count).to eq(1)
expect(ActionMailer::Base.deliveries.first.to).to eq([order.email])
end
@@ -114,14 +114,14 @@ describe Spree::OrderMailer do
end
it "sets a reply-to of the enterprise email" do
Spree::OrderMailer.confirm_email_for_customer(order.id).deliver
Spree::OrderMailer.confirm_email_for_customer(order.id).deliver_now
expect(ActionMailer::Base.deliveries.first.reply_to).to eq([distributor.contact.email])
end
end
describe "for shops" do
it "sends an email to the shop owner when given an order" do
Spree::OrderMailer.confirm_email_for_shop(order.id).deliver
Spree::OrderMailer.confirm_email_for_shop(order.id).deliver_now
expect(ActionMailer::Base.deliveries.count).to eq(1)
expect(ActionMailer::Base.deliveries.first.to).to eq([distributor.contact.email])
end
@@ -129,7 +129,7 @@ describe Spree::OrderMailer do
it "sends an email even if a footer_email is given" do
# Testing bug introduced by a9c37c162e1956028704fbdf74ce1c56c5b3ce7d
ContentConfig.footer_email = "email@example.com"
Spree::OrderMailer.confirm_email_for_shop(order.id).deliver
Spree::OrderMailer.confirm_email_for_shop(order.id).deliver_now
expect(ActionMailer::Base.deliveries.count).to eq(1)
end
end

View File

@@ -99,7 +99,7 @@ describe ProducerMailer, type: :mailer do
it "sends no mail when the producer has no orders" do
expect do
ProducerMailer.order_cycle_report(s3, order_cycle).deliver
ProducerMailer.order_cycle_report(s3, order_cycle).deliver_now
end.to change(ActionMailer::Base.deliveries, :count).by(0)
end

View File

@@ -30,7 +30,7 @@ describe Spree::ShipmentMailer do
it "shipment_email accepts an shipment id as an alternative to an Shipment object" do
expect(Spree::Shipment).to receive(:find).with(shipment.id).and_return(shipment)
expect {
Spree::ShipmentMailer.shipped_email(shipment.id).deliver
Spree::ShipmentMailer.shipped_email(shipment.id).deliver_now
}.to_not raise_error
end
end

View File

@@ -21,7 +21,7 @@ describe SubscriptionMailer, type: :mailer do
before do
changes[order.line_items.first.id] = 2
expect do
SubscriptionMailer.placement_email(order, changes).deliver
SubscriptionMailer.placement_email(order, changes).deliver_now
end.to change{ SubscriptionMailer.deliveries.count }.by(1)
end
@@ -35,7 +35,7 @@ describe SubscriptionMailer, type: :mailer do
context "and changes have not been made to the order" do
before do
expect do
SubscriptionMailer.placement_email(order, {}).deliver
SubscriptionMailer.placement_email(order, {}).deliver_now
end.to change{ SubscriptionMailer.deliveries.count }.by(1)
end
@@ -56,7 +56,7 @@ describe SubscriptionMailer, type: :mailer do
let(:body) { email.body.encoded }
before do
SubscriptionMailer.placement_email(order, {}).deliver
SubscriptionMailer.placement_email(order, {}).deliver_now
end
context "when the customer has a user account" do
@@ -103,7 +103,7 @@ describe SubscriptionMailer, type: :mailer do
before do
expect do
SubscriptionMailer.confirmation_email(order).deliver
SubscriptionMailer.confirmation_email(order).deliver_now
end.to change{ SubscriptionMailer.deliveries.count }.by(1)
end
@@ -143,7 +143,7 @@ describe SubscriptionMailer, type: :mailer do
before do
expect do
SubscriptionMailer.empty_email(order, {}).deliver
SubscriptionMailer.empty_email(order, {}).deliver_now
end.to change{ SubscriptionMailer.deliveries.count }.by(1)
end
@@ -164,7 +164,7 @@ describe SubscriptionMailer, type: :mailer do
order.errors.add(:base, "This is a payment failure error")
expect do
SubscriptionMailer.failed_payment_email(order).deliver
SubscriptionMailer.failed_payment_email(order).deliver_now
end.to change{ SubscriptionMailer.deliveries.count }.by(1)
end
@@ -215,7 +215,7 @@ describe SubscriptionMailer, type: :mailer do
allow(summary).to receive(:order_count) { 37 }
allow(summary).to receive(:issue_count) { 0 }
allow(summary).to receive(:issues) { {} }
SubscriptionMailer.placement_summary_email(summary).deliver
SubscriptionMailer.placement_summary_email(summary).deliver_now
end
it "sends the email, which notifies the enterprise that all orders were successfully processed" do
@@ -240,7 +240,7 @@ describe SubscriptionMailer, type: :mailer do
context "when no unrecorded issues are present" do
it "sends the email, which notifies the enterprise that some issues were encountered" do
SubscriptionMailer.placement_summary_email(summary).deliver
SubscriptionMailer.placement_summary_email(summary).deliver_now
expect(body).to include I18n.t("#{scope}.placement_summary_email.intro", shop: shop.name)
expect(body).to include I18n.t("#{scope}.summary_overview.total", count: 37)
expect(body).to include I18n.t("#{scope}.summary_overview.success_some", count: 35)
@@ -268,7 +268,7 @@ describe SubscriptionMailer, type: :mailer do
it "sends the email, which notifies the enterprise that some issues were encountered" do
expect(summary).to receive(:orders_affected_by).with(:other) { [order3, order4] }
SubscriptionMailer.placement_summary_email(summary).deliver
SubscriptionMailer.placement_summary_email(summary).deliver_now
expect(body).to include I18n.t("#{scope}.summary_detail.processing.title", count: 2)
expect(body).to include I18n.t("#{scope}.summary_detail.processing.explainer")
expect(body).to include I18n.t("#{scope}.summary_detail.other.title", count: 2)
@@ -291,7 +291,7 @@ describe SubscriptionMailer, type: :mailer do
allow(summary).to receive(:issue_count) { 2 }
allow(summary).to receive(:issues) { { changes: { 1 => nil, 2 => nil } } }
allow(summary).to receive(:orders_affected_by) { [order1, order2] }
SubscriptionMailer.placement_summary_email(summary).deliver
SubscriptionMailer.placement_summary_email(summary).deliver_now
end
it "sends the email, which notifies the enterprise that some issues were encountered" do
@@ -325,7 +325,7 @@ describe SubscriptionMailer, type: :mailer do
allow(summary).to receive(:order_count) { 37 }
allow(summary).to receive(:issue_count) { 0 }
allow(summary).to receive(:issues) { {} }
SubscriptionMailer.confirmation_summary_email(summary).deliver
SubscriptionMailer.confirmation_summary_email(summary).deliver_now
end
it "sends the email, which notifies the enterprise that all orders were successfully processed" do
@@ -350,7 +350,7 @@ describe SubscriptionMailer, type: :mailer do
context "when no unrecorded issues are present" do
it "sends the email, which notifies the enterprise that some issues were encountered" do
SubscriptionMailer.confirmation_summary_email(summary).deliver
SubscriptionMailer.confirmation_summary_email(summary).deliver_now
expect(body).to include I18n.t("#{scope}.confirmation_summary_email.intro", shop: shop.name)
expect(body).to include I18n.t("#{scope}.summary_overview.total", count: 37)
expect(body).to include I18n.t("#{scope}.summary_overview.success_some", count: 35)
@@ -378,7 +378,7 @@ describe SubscriptionMailer, type: :mailer do
it "sends the email, which notifies the enterprise that some issues were encountered" do
expect(summary).to receive(:orders_affected_by).with(:other) { [order3, order4] }
SubscriptionMailer.confirmation_summary_email(summary).deliver
SubscriptionMailer.confirmation_summary_email(summary).deliver_now
expect(body).to include I18n.t("#{scope}.summary_detail.failed_payment.title", count: 2)
expect(body).to include I18n.t("#{scope}.summary_detail.failed_payment.explainer")
expect(body).to include I18n.t("#{scope}.summary_detail.other.title", count: 2)
@@ -401,7 +401,7 @@ describe SubscriptionMailer, type: :mailer do
allow(summary).to receive(:issue_count) { 2 }
allow(summary).to receive(:issues) { { changes: { 1 => nil, 2 => nil } } }
allow(summary).to receive(:orders_affected_by) { [order1, order2] }
SubscriptionMailer.confirmation_summary_email(summary).deliver
SubscriptionMailer.confirmation_summary_email(summary).deliver_now
end
it "sends the email, which notifies the enterprise that some issues were encountered" do

View File

@@ -15,7 +15,7 @@ describe Spree::TestMailer do
it "confirm_email accepts a user id as an alternative to a User object" do
expect(Spree.user_class).to receive(:find).with(user.id).and_return(user)
expect {
Spree::TestMailer.test_email(user.id).deliver
Spree::TestMailer.test_email(user.id).deliver_now
}.to_not raise_error
end
end

View File

@@ -21,7 +21,7 @@ describe Spree::UserMailer do
describe '#signup_confirmation' do
it "sends email when given a user" do
Spree::UserMailer.signup_confirmation(user).deliver
Spree::UserMailer.signup_confirmation(user).deliver_now
expect(ActionMailer::Base.deliveries.count).to eq(1)
end
@@ -35,13 +35,13 @@ describe Spree::UserMailer do
it "sends email in user locale when user locale is defined" do
user.locale = 'es'
Spree::UserMailer.signup_confirmation(user).deliver
Spree::UserMailer.signup_confirmation(user).deliver_now
expect(ActionMailer::Base.deliveries.first.body).to include "Gracias por unirte"
end
it "sends email in default locale when user locale is not available" do
user.locale = 'cn'
Spree::UserMailer.signup_confirmation(user).deliver
Spree::UserMailer.signup_confirmation(user).deliver_now
expect(ActionMailer::Base.deliveries.first.body).to include "Obrigada por juntar-se"
end
end
@@ -50,7 +50,7 @@ describe Spree::UserMailer do
# adapted from https://github.com/spree/spree_auth_devise/blob/70737af/spec/mailers/user_mailer_spec.rb
describe '#reset_password_instructions' do
describe 'message contents' do
let(:message) { described_class.reset_password_instructions(user, nil).deliver }
let(:message) { described_class.reset_password_instructions(user, nil).deliver_now }
context 'subject includes' do
it 'translated devise instructions' do
@@ -86,7 +86,7 @@ describe Spree::UserMailer do
describe 'legacy support for User object' do
it 'sends an email' do
expect do
Spree::UserMailer.reset_password_instructions(user, nil).deliver
Spree::UserMailer.reset_password_instructions(user, nil).deliver_now
end.to change(ActionMailer::Base.deliveries, :size).by(1)
end
end

View File

@@ -30,7 +30,7 @@ describe ProxyOrder, type: :model do
let(:order) { create(:completed_order_with_totals) }
it "returns true and sets canceled_at to the current time, and cancels the order" do
expect(Spree::OrderMailer).to receive(:cancel_email) { double(:email, deliver: true) }
expect(Spree::OrderMailer).to receive(:cancel_email) { double(:email, deliver_now: true) }
expect(proxy_order.cancel).to be true
expect_cancelled_now proxy_order
expect(order.reload.state).to eq 'canceled'
@@ -107,7 +107,7 @@ describe ProxyOrder, type: :model do
context "and the order has already been cancelled" do
before do
allow(Spree::OrderMailer).to receive(:cancel_email) { double(:email, deliver: true) }
allow(Spree::OrderMailer).to receive(:cancel_email) { double(:email, deliver_now: true) }
while !order.completed? do break unless order.next! end
order.cancel
end
@@ -147,7 +147,7 @@ describe ProxyOrder, type: :model do
context "and the order has been cancelled" do
before do
allow(Spree::OrderMailer).to receive(:cancel_email) { double(:email, deliver: true) }
allow(Spree::OrderMailer).to receive(:cancel_email) { double(:email, deliver_now: true) }
while !order.completed? do break unless order.next! end
order.cancel
end

View File

@@ -123,7 +123,7 @@ describe Spree::Order do
order_id = args[0]
mail_message
}
expect(mail_message).to receive :deliver
expect(mail_message).to receive :deliver_now
order.cancel!
expect(order_id).to eq order.id
end
@@ -133,7 +133,7 @@ describe Spree::Order do
allow(shipment).to receive(:ensure_correct_adjustment)
allow(shipment).to receive(:update_order)
allow(Spree::OrderMailer).to receive(:cancel_email).and_return(mail_message = double)
allow(mail_message).to receive :deliver
allow(mail_message).to receive :deliver_now
allow(order).to receive :has_available_shipment
end
@@ -143,7 +143,7 @@ describe Spree::Order do
before do
# Stubs methods that cause unwanted side effects in this test
allow(Spree::OrderMailer).to receive(:cancel_email).and_return(mail_message = double)
allow(mail_message).to receive :deliver
allow(mail_message).to receive :deliver_now
allow(order).to receive :has_available_shipment
allow(order).to receive :restock_items!
allow(shipment).to receive(:cancel!)

View File

@@ -179,7 +179,7 @@ describe Spree::Order do
# Stub this method as it's called due to a callback
# and it's irrelevant to this test
allow(order).to receive :has_available_shipment
allow(Spree::OrderMailer).to receive_message_chain :confirm_email, :deliver
allow(Spree::OrderMailer).to receive_message_chain :confirm_email, :deliver_now
adjustments = double
allow(order).to receive_messages adjustments: adjustments
expect(adjustments).to receive(:update_all).with(state: 'closed')

View File

@@ -376,7 +376,7 @@ describe Spree::Shipment do
shipment_id = args[0]
mail_message
}
expect(mail_message).to receive :deliver
expect(mail_message).to receive :deliver_now
shipment.ship!
expect(shipment_id).to eq shipment.id
end