Add RecurringDonationChangeAmountNonprofitEmailJob
This commit is contained in:
parent
3aa1075c76
commit
cc45ec820a
5 changed files with 2 additions and 37 deletions
|
@ -1,7 +1,7 @@
|
||||||
class RecurringDonationChangeAmountNonprofitEmailJob < ApplicationJob
|
class RecurringDonationChangeAmountNonprofitEmailJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :default
|
||||||
|
|
||||||
def perform(*args)
|
def perform(recurring_donation, previous_amount)
|
||||||
# Do something later
|
DonationMailer.nonprofit_recurring_donation_change_amount(recurring_donation.id, previous_amount).deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +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 NonprofitRecurringDonationChangeAmountJob < EmailJob
|
|
||||||
attr_reader :donation_id, :previous_amount
|
|
||||||
|
|
||||||
def initialize(donation_id, previous_amount = nil)
|
|
||||||
@donation_id = donation_id
|
|
||||||
@previous_amount = previous_amount
|
|
||||||
end
|
|
||||||
|
|
||||||
def perform
|
|
||||||
DonationMailer.nonprofit_recurring_donation_change_amount(@donation_id, @previous_amount).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -74,7 +74,6 @@ module UpdateRecurringDonations
|
||||||
donation.save!
|
donation.save!
|
||||||
end
|
end
|
||||||
RecurringDonationChangeAmountJob.perform_later(rd, previous_amount)
|
RecurringDonationChangeAmountJob.perform_later(rd, previous_amount)
|
||||||
EmailJobQueue.queue(JobTypes::NonprofitRecurringDonationChangeAmountJob, rd.id, previous_amount)
|
|
||||||
rd
|
rd
|
||||||
end
|
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::NonprofitRecurringDonationChangeAmountJob do
|
|
||||||
describe '.perform' do
|
|
||||||
it 'calls the correct active mailer' do
|
|
||||||
expect(DonationMailer).to receive(:nonprofit_recurring_donation_change_amount).with(1, 100).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
|
||||||
|
|
||||||
job = JobTypes::NonprofitRecurringDonationChangeAmountJob.new(1, 100)
|
|
||||||
job.perform
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -93,8 +93,6 @@ describe UpdateRecurringDonations do
|
||||||
orig_rd = recurring_donation.attributes.with_indifferent_access
|
orig_rd = recurring_donation.attributes.with_indifferent_access
|
||||||
orig_donation = recurring_donation.donation.attributes.with_indifferent_access
|
orig_donation = recurring_donation.donation.attributes.with_indifferent_access
|
||||||
|
|
||||||
expect_email_queued.with(JobTypes::NonprofitRecurringDonationChangeAmountJob, recurring_donation.id, orig_rd['amount'])
|
|
||||||
|
|
||||||
result = nil
|
result = nil
|
||||||
expect {
|
expect {
|
||||||
result = UpdateRecurringDonations.update_amount(recurring_donation,
|
result = UpdateRecurringDonations.update_amount(recurring_donation,
|
||||||
|
|
Loading…
Reference in a new issue