Add RecurringDonationChangeAmountNonprofitEmailJob

This commit is contained in:
Eric Schultz 2019-11-07 14:14:29 -06:00
parent 3aa1075c76
commit cc45ec820a
5 changed files with 2 additions and 37 deletions

View file

@ -1,7 +1,7 @@
class RecurringDonationChangeAmountNonprofitEmailJob < ApplicationJob
queue_as :default
def perform(*args)
# Do something later
def perform(recurring_donation, previous_amount)
DonationMailer.nonprofit_recurring_donation_change_amount(recurring_donation.id, previous_amount).deliver_now
end
end

View file

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

View file

@ -74,7 +74,6 @@ module UpdateRecurringDonations
donation.save!
end
RecurringDonationChangeAmountJob.perform_later(rd, previous_amount)
EmailJobQueue.queue(JobTypes::NonprofitRecurringDonationChangeAmountJob, rd.id, previous_amount)
rd
end

View file

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

View file

@ -93,8 +93,6 @@ 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::NonprofitRecurringDonationChangeAmountJob, recurring_donation.id, orig_rd['amount'])
result = nil
expect {
result = UpdateRecurringDonations.update_amount(recurring_donation,