From d544242ae72589b62aa10bcea9e6368e67ca497e Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Fri, 8 Nov 2019 14:58:05 -0600 Subject: [PATCH] Correct bugs in how payment notification jobs are enqueued --- .../shared_rd_donation_value_context.rb | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/spec/support/contexts/shared_rd_donation_value_context.rb b/spec/support/contexts/shared_rd_donation_value_context.rb index 67d65ec1..7d5937ab 100644 --- a/spec/support/contexts/shared_rd_donation_value_context.rb +++ b/spec/support/contexts/shared_rd_donation_value_context.rb @@ -327,13 +327,8 @@ RSpec.shared_context :shared_rd_donation_value_context do def before_each_success(expect_charge = true) expect(InsertDonation).to receive(:insert_donation).and_wrap_original do |m, *args| - expect { - expect { - result = m.call(*args) - }.to have_enqueued_job(PaymentNotificationJob).with(result, supporter.local) - }.to have_enqueued_job(WeMoveExecuteForDonationsJob) + result = m.call(*args) @donation_id = result.id - result end @@ -370,13 +365,8 @@ RSpec.shared_context :shared_rd_donation_value_context do end def before_each_sepa_success - expect(InsertDonation).to receive(:insert_donation).and_wrap_original do |m, *args| - expect { - expect { - result = m.call(*args) - }.to have_enqueued_job(DirectDebitCreateJob).with(result.id, supporter.local) - }.to have_enqueued_job(WeMoveExecuteForDonationsJob) + result = m.call(*args) @donation_id = result.id result end @@ -395,6 +385,12 @@ RSpec.shared_context :shared_rd_donation_value_context do if data[:recurring_donation] expect(result['recurring_donation'].attributes).to eq expected[:recurring_donation] end + if (data[:sepa]) + expect(DirectDebitCreateJob).to have_been_enqueued.with(result['donation']['id'], supporter.locale) + else + expect(PaymentNotificationJob).to have_been_enqueued.with(result['donation'], supporter.locale) + end + expect(WeMoveExecuteForDonationsJob).to have_been_enqueued result end @@ -412,6 +408,12 @@ RSpec.shared_context :shared_rd_donation_value_context do if data[:recurring_donation] expect(result['recurring_donation'].attributes).to eq expected[:recurring_donation] end + if (data[:sepa]) + + else + expect(PaymentNotificationJob).to have_been_enqueued.with(result['donation'], supporter.locale) + end + expect(WeMoveExecuteForDonationsJob).to have_been_enqueued result end @@ -436,6 +438,13 @@ RSpec.shared_context :shared_rd_donation_value_context do if data[:recurring_donation] expect(result['recurring_donation'].attributes).to eq expected[:recurring_donation] end + + if (data[:sepa]) + + else + expect(PaymentNotificationJob).to have_been_enqueued.with(result['donation'], supporter.locale) + end + expect(WeMoveExecuteForDonationsJob).to have_been_enqueued result end