Add RecurringDonationChangeAmountJob
This commit is contained in:
parent
ff1a8b92f5
commit
b6292ab7aa
7 changed files with 28 additions and 34 deletions
|
@ -0,0 +1,7 @@
|
|||
class RecurringDonationChangeAmountDonorEmailJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(recurring_donation, previous_amount)
|
||||
DonationMailer.donor_recurring_donation_change_amount(recurring_donation.id, previous_amount).deliver_now
|
||||
end
|
||||
end
|
8
app/jobs/recurring_donation_change_amount_job.rb
Normal file
8
app/jobs/recurring_donation_change_amount_job.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class RecurringDonationChangeAmountJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(recurring_donation, previous_amount)
|
||||
RecurringDonationChangeAmountDonorEmailJob.perform_later(recurring_donation, previous_amount)
|
||||
RecurringDonationChangeAmountNonprofitEmailJob.perform_later(recurring_donation, previous_amount)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
class RecurringDonationChangeAmountNonprofitEmailJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(*args)
|
||||
# Do something 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 DonorRecurringDonationChangeAmountJob < 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.donor_recurring_donation_change_amount(@donation_id, @previous_amount).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -73,8 +73,8 @@ module UpdateRecurringDonations
|
|||
rd.save!
|
||||
donation.save!
|
||||
end
|
||||
RecurringDonationChangeAmountJob.perform_later(rd, previous_amount)
|
||||
EmailJobQueue.queue(JobTypes::NonprofitRecurringDonationChangeAmountJob, rd.id, previous_amount)
|
||||
EmailJobQueue.queue(JobTypes::DonorRecurringDonationChangeAmountJob, rd.id, previous_amount)
|
||||
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::DonorRecurringDonationChangeAmountJob do
|
||||
describe '.perform' do
|
||||
it 'calls the correct active mailer' do
|
||||
expect(DonationMailer).to receive(:donor_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::DonorRecurringDonationChangeAmountJob.new(1, 100)
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
end
|
|
@ -93,10 +93,13 @@ describe UpdateRecurringDonations do
|
|||
orig_rd = recurring_donation.attributes.with_indifferent_access
|
||||
orig_donation = recurring_donation.donation.attributes.with_indifferent_access
|
||||
|
||||
expect_email_queued.with(JobTypes::DonorRecurringDonationChangeAmountJob, recurring_donation.id, orig_rd['amount'])
|
||||
expect_email_queued.with(JobTypes::NonprofitRecurringDonationChangeAmountJob, recurring_donation.id, orig_rd['amount'])
|
||||
|
||||
result = UpdateRecurringDonations.update_amount(recurring_donation, source_token.token, 1000)
|
||||
result = nil
|
||||
expect {
|
||||
result = UpdateRecurringDonations.update_amount(recurring_donation,
|
||||
source_token.token, 1000)
|
||||
}.to have_enqueue_with(RecurringDonationChangeAmountJob).with(recurring_donation, orig_rd['amount'])
|
||||
|
||||
expectations = {
|
||||
donation: orig_donation.merge(amount: 1000, card_id: source_token.tokenizable.id),
|
||||
|
|
Loading…
Reference in a new issue