Add ExportRecurringDonationsCompletedJob
This commit is contained in:
parent
24ba568756
commit
e9a01c76ef
4 changed files with 8 additions and 32 deletions
7
app/jobs/export_recurring_donations_completed_job.rb
Normal file
7
app/jobs/export_recurring_donations_completed_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class ExportRecurringDonationsCompletedJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(export)
|
||||||
|
ExportMailer.export_recurring_donations_completed_notification(@export).deliver_now
|
||||||
|
end
|
||||||
|
end
|
|
@ -61,7 +61,7 @@ module ExportRecurringDonations
|
||||||
export.ended = Time.now
|
export.ended = Time.now
|
||||||
export.save!
|
export.save!
|
||||||
|
|
||||||
ExportMailer.delay.export_recurring_donations_completed_notification(export)
|
ExportRecurringDonationsCompletedJob.perform_later(export)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
if export
|
if export
|
||||||
export.status = :failed
|
export.status = :failed
|
||||||
|
|
|
@ -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 ExportRecurringDonationsCompletedJob < EmailJob
|
|
||||||
attr_reader :export
|
|
||||||
|
|
||||||
def initialize(export)
|
|
||||||
@export = export
|
|
||||||
end
|
|
||||||
|
|
||||||
def perform
|
|
||||||
ExportMailer.export_recurring_donations_completed_notification(@export).deliver
|
|
||||||
end
|
|
||||||
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::ExportRecurringDonationsCompletedJob do
|
|
||||||
describe '.perform' do
|
|
||||||
it 'calls the correct active mailer' do
|
|
||||||
expect(ExportMailer).to receive(:export_recurring_donations_completed_notification).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
|
||||||
|
|
||||||
job = JobTypes::ExportRecurringDonationsCompletedJob.new(1)
|
|
||||||
job.perform
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue