diff --git a/app/jobs/export_recurring_donations_completed_job.rb b/app/jobs/export_recurring_donations_completed_job.rb new file mode 100644 index 00000000..e39c22dd --- /dev/null +++ b/app/jobs/export_recurring_donations_completed_job.rb @@ -0,0 +1,7 @@ +class ExportRecurringDonationsCompletedJob < ApplicationJob + queue_as :default + + def perform(export) + ExportMailer.export_recurring_donations_completed_notification(@export).deliver_now + end +end diff --git a/lib/export/export_recurring_donations.rb b/lib/export/export_recurring_donations.rb index 9d9e1d23..b70df08f 100644 --- a/lib/export/export_recurring_donations.rb +++ b/lib/export/export_recurring_donations.rb @@ -61,7 +61,7 @@ module ExportRecurringDonations export.ended = Time.now export.save! - ExportMailer.delay.export_recurring_donations_completed_notification(export) + ExportRecurringDonationsCompletedJob.perform_later(export) rescue StandardError => e if export export.status = :failed diff --git a/lib/job_types/export_recurring_donations_completed_job.rb b/lib/job_types/export_recurring_donations_completed_job.rb deleted file mode 100644 index 8871a91d..00000000 --- a/lib/job_types/export_recurring_donations_completed_job.rb +++ /dev/null @@ -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 diff --git a/spec/lib/job_types/export_recurring_donations_completed_job_spec.rb b/spec/lib/job_types/export_recurring_donations_completed_job_spec.rb deleted file mode 100644 index 94cdf114..00000000 --- a/spec/lib/job_types/export_recurring_donations_completed_job_spec.rb +++ /dev/null @@ -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