diff --git a/app/jobs/we_move_execute_for_donations_job.rb b/app/jobs/we_move_execute_for_donations_job.rb new file mode 100644 index 00000000..ce7cba77 --- /dev/null +++ b/app/jobs/we_move_execute_for_donations_job.rb @@ -0,0 +1,7 @@ +class WeMoveExecuteForDonationsJob < ApplicationJob + queue_as :default + + def perform(donation) + QueueDonations.execute_for_donation(donation.id) + end +end diff --git a/lib/insert/insert_donation.rb b/lib/insert/insert_donation.rb index 05d57b15..17f86b43 100644 --- a/lib/insert/insert_donation.rb +++ b/lib/insert/insert_donation.rb @@ -44,7 +44,7 @@ module InsertDonation update_donation_keys(result) result['activity'] = InsertActivities.for_one_time_donations([result['payment'].id]) PaymentNotificationJob.perform_later result['donation'], entities[:supporter_id].locale - QueueDonations.delay.execute_for_donation(result['donation'].id) + WeMoveExecuteForDonationsJob.perform_later(result['donation']) result end @@ -85,7 +85,7 @@ module InsertDonation ]).returning('*') ).first result['activity'] = InsertActivities.for_offsite_donations([result['payment']['id']]) - QueueDonations.delay.execute_for_donation(result['donation'].id) + WeMoveExecuteForDonationsJob.perform_later(result['donation']) { status: 200, json: result } end @@ -107,7 +107,7 @@ module InsertDonation DirectDebitCreateJob.perform_later(result['donation'].id, locale_for_supporter(result['donation'].supporter.id)) - QueueDonations.delay.execute_for_donation(result['donation'].id) + WeMoveExecuteForDonationsJob.perform_later(result['donation']) # do this for making test consistent result['activity'] = {} result diff --git a/lib/insert/insert_recurring_donation.rb b/lib/insert/insert_recurring_donation.rb index f48bdf5b..acdd2a16 100644 --- a/lib/insert/insert_recurring_donation.rb +++ b/lib/insert/insert_recurring_donation.rb @@ -71,7 +71,7 @@ module InsertRecurringDonation end # Send receipts PaymentNotificationJob.perform_later result['donation'], entities[:supporter_id].locale - QueueDonations.delay.execute_for_donation(result['donation']['id']) + WeMoveExecuteForDonationsJob.perform_later(result['donation']) result end @@ -96,7 +96,7 @@ module InsertRecurringDonation DonorDirectDebitNotificationJob.perform_later(Donation.find(result['donation']['id']), locale_for_supporter(result['donation']['supporter_id']); - QueueDonations.delay.execute_for_donation(result['donation']['id']) + WeMoveExecuteForDonationsJob.perform_later(result['donation']) { status: 200, json: result } end diff --git a/spec/lib/query/query_payments_spec.rb b/spec/lib/query/query_payments_spec.rb index ca0439c9..e3159dce 100644 --- a/spec/lib/query/query_payments_spec.rb +++ b/spec/lib/query/query_payments_spec.rb @@ -168,8 +168,6 @@ describe QueryPayments do @stripe_charge_id = a['id'] a } - - allow(QueueDonations).to receive(:execute_for_donation) end let(:charge_amount_small) { 200 } diff --git a/spec/support/contexts/shared_rd_donation_value_context.rb b/spec/support/contexts/shared_rd_donation_value_context.rb index 9510a40c..8f367cc4 100644 --- a/spec/support/contexts/shared_rd_donation_value_context.rb +++ b/spec/support/contexts/shared_rd_donation_value_context.rb @@ -328,12 +328,12 @@ 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 { - result = m.call(*args) - }.to have_enqueued_job(PaymentNotificationJob).with(result, supporter.local) + expect { + result = m.call(*args) + }.to have_enqueued_job(PaymentNotificationJob).with(result, supporter.local) + }.to have_enqueued_job(WeMoveExecuteForDonationsJob) @donation_id = result.id - expect(QueueDonations).to receive(:execute_for_donation).with(@donation_id) - result end @@ -370,14 +370,13 @@ 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 { - result = m.call(*args) - }.to have_enqueued_job(DirectDebitCreateJob).with(result.id, supporter.local) - - + expect { + expect(InsertDonation).to receive(:insert_donation).and_wrap_original do |m, *args| + expect { + result = m.call(*args) + }.to have_enqueued_job(DirectDebitCreateJob).with(result.id, supporter.local) + }.to have_enqueued_job(WeMoveExecuteForDonationsJob) @donation_id = result.id - expect(QueueDonations).to receive(:execute_for_donation).with(@donation_id) result end end