Add CreateWeMoveExecuteForDonationsJob

This commit is contained in:
Eric Schultz 2019-11-07 15:42:28 -06:00
parent 34e67f5577
commit 5236eda39d
5 changed files with 22 additions and 18 deletions

View file

@ -0,0 +1,7 @@
class WeMoveExecuteForDonationsJob < ApplicationJob
queue_as :default
def perform(donation)
QueueDonations.execute_for_donation(donation.id)
end
end

View file

@ -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

View file

@ -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

View file

@ -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 }

View file

@ -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