Add RecurringDonationCancelledJob
This commit is contained in:
parent
0d70861a19
commit
3aa1075c76
4 changed files with 8 additions and 32 deletions
7
app/jobs/recurring_donation_cancelled_job.rb
Normal file
7
app/jobs/recurring_donation_cancelled_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class RecurringDonationCancelledJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(donation)
|
||||
DonationMailer.nonprofit_recurring_donation_cancellation(donation.id).deliver_later
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class NonprofitRecurringDonationCancellationJob < EmailJob
|
||||
attr_reader :donation_id
|
||||
|
||||
def initialize(donation_id)
|
||||
@donation_id = donation_id
|
||||
end
|
||||
|
||||
def perform
|
||||
DonationMailer.nonprofit_recurring_donation_cancellation(@donation_id).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -98,7 +98,7 @@ module UpdateRecurringDonations
|
|||
rd = QueryRecurringDonations.fetch_for_edit(rd_id)['recurring_donation']
|
||||
InsertSupporterNotes.create([{ supporter_id: rd['supporter_id'], content: "This supporter's recurring donation for $#{Format::Currency.cents_to_dollars(rd['amount'])} was cancelled by #{rd['cancelled_by']} on #{Format::Date.simple(rd['cancelled_at'])}", user_id: 540 }])
|
||||
unless dont_notify_nonprofit
|
||||
DonationMailer.delay.nonprofit_recurring_donation_cancellation(rd['donation_id'])
|
||||
RecurringDonationCancelledJob.perform_later(Donation.find(rd['donation_id']))
|
||||
end
|
||||
rd
|
||||
end
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'rails_helper.rb'
|
||||
|
||||
describe JobTypes::NonprofitRecurringDonationCancellationJob do
|
||||
describe '.perform' do
|
||||
it 'calls the correct active mailer' do
|
||||
expect(DonationMailer).to receive(:nonprofit_recurring_donation_cancellation).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
||||
|
||||
job = JobTypes::NonprofitRecurringDonationCancellationJob.new(1)
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue