From c28b65f772aa676a447eb04e7d05c472c2a238dd Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Thu, 21 Jan 2021 09:12:40 -0800 Subject: [PATCH] update subs jobs delivery methods --- app/jobs/subscription_confirm_job.rb | 2 +- .../services/order_management/subscriptions/summarizer.rb | 2 ++ spec/jobs/subscription_confirm_job_spec.rb | 8 +++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/jobs/subscription_confirm_job.rb b/app/jobs/subscription_confirm_job.rb index 7c83fac8bb..09105ba0e7 100644 --- a/app/jobs/subscription_confirm_job.rb +++ b/app/jobs/subscription_confirm_job.rb @@ -97,7 +97,7 @@ class SubscriptionConfirmJob < ActiveJob::Base def send_payment_authorization_emails(order) order.payments.each do |payment| if payment.cvv_response_message.present? - PaymentMailer.authorize_payment(payment).deliver + PaymentMailer.authorize_payment(payment).deliver_now end end end diff --git a/engines/order_management/app/services/order_management/subscriptions/summarizer.rb b/engines/order_management/app/services/order_management/subscriptions/summarizer.rb index fe02a9ad9c..86c7deadea 100644 --- a/engines/order_management/app/services/order_management/subscriptions/summarizer.rb +++ b/engines/order_management/app/services/order_management/subscriptions/summarizer.rb @@ -35,12 +35,14 @@ module OrderManagement record_issue(type, order, line2) end + # This uses `deliver_now` since it's called from inside a job def send_placement_summary_emails @summaries.values.each do |summary| SubscriptionMailer.placement_summary_email(summary).deliver_now end end + # This uses `deliver_now` since it's called from inside a job def send_confirmation_summary_emails @summaries.values.each do |summary| SubscriptionMailer.confirmation_summary_email(summary).deliver_now diff --git a/spec/jobs/subscription_confirm_job_spec.rb b/spec/jobs/subscription_confirm_job_spec.rb index dcecb5a6ac..52f6324dcc 100644 --- a/spec/jobs/subscription_confirm_job_spec.rb +++ b/spec/jobs/subscription_confirm_job_spec.rb @@ -230,11 +230,9 @@ describe SubscriptionConfirmJob do end it "sends only a subscription confirm email, no regular confirmation emails" do - ActionMailer::Base.deliveries.clear expect{ job.send(:confirm_order!, order) }.to_not enqueue_job ConfirmOrderJob expect(job).to have_received(:send_confirmation_email).once expect(job).to have_received(:send_payment_authorization_emails).once - expect(ActionMailer::Base.deliveries.count).to be 1 end end end @@ -277,7 +275,7 @@ describe SubscriptionConfirmJob do describe "#send_payment_authorization_emails" do let(:order) { instance_double(Spree::Order) } - let(:mail_mock) { double(:mailer_mock, deliver: true) } + let(:mail_mock) { double(:mailer_mock, deliver_now: true) } let(:payment) { create(:payment, amount: 10) } before do @@ -289,14 +287,14 @@ describe SubscriptionConfirmJob do allow(payment).to receive(:cvv_response_message) { "http://redirect_url" } job.send(:send_payment_authorization_emails, order) expect(PaymentMailer).to have_received(:authorize_payment) - expect(mail_mock).to have_received(:deliver) + expect(mail_mock).to have_received(:deliver_now) end it "does not send authorization email if no payment requires it" do allow(payment).to receive(:cvv_response_message) { nil } job.send(:send_payment_authorization_emails, order) expect(PaymentMailer).not_to have_received(:authorize_payment) - expect(mail_mock).not_to have_received(:deliver) + expect(mail_mock).not_to have_received(:deliver_now) end end end