AddRefundNotificationNonprofitEmailJob

This commit is contained in:
Eric Schultz 2019-11-07 14:33:01 -06:00
parent cc45ec820a
commit 78e803b1d6
5 changed files with 3 additions and 34 deletions

View file

@ -3,6 +3,6 @@ class RefundNotificationJob < ApplicationJob
def perform(refund)
RefundNotificationJobDonorEmail.perform_later(refund)
RefundNotificationJobNonprofitEmail.perform_later(refund)
RefundNotificationNonprofitEmailJob.perform_later(refund)
end
end

View file

@ -1,7 +1,7 @@
class RefundNotificationNonprofitEmailJob < ApplicationJob
queue_as :default
def perform(*args)
# Do something later
def perform(refund)
NonprofitMailer.refund_notification(refund.id).deliver_now
end
end

View file

@ -67,7 +67,6 @@ module InsertRefunds
Qx.update(:payments).set("refund_total=refund_total + #{h['amount'].to_i}").ts.where(id: original_payment['id']).execute
# Send the refund receipts in a delayed job
RefundNotificationJob.perform_later Refund.find(refund_row['id'])
Delayed::Job.enqueue JobTypes::NonprofitRefundNotificationJob.new(refund_row['id'])
{ 'payment' => payment_row, 'refund' => refund_row }
end
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
module JobTypes
class NonprofitRefundNotificationJob < EmailJob
attr_reader :refund_id
def initialize(refund_id)
@refund_id = refund_id
end
def perform
NonprofitMailer.refund_notification(@refund_id).deliver
end
end
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::NonprofitRefundNotificationJob do
describe '.perform' do
it 'calls the correct active mailer' do
expect(NonprofitMailer).to receive(:refund_notification).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
job = JobTypes::NonprofitRefundNotificationJob.new(1)
job.perform
end
end
end