diff --git a/app/jobs/export_payments_failed_job.rb b/app/jobs/export_payments_failed_job.rb new file mode 100644 index 00000000..d8be1f6a --- /dev/null +++ b/app/jobs/export_payments_failed_job.rb @@ -0,0 +1,7 @@ +class ExportPaymentsFailedJob < ApplicationJob + queue_as :default + + def perform(export) + ExportMailer.export_payments_failed_notification(export).deliver_now + end +end diff --git a/lib/export/export_payments.rb b/lib/export/export_payments.rb index 7f045244..fd1f0f60 100644 --- a/lib/export/export_payments.rb +++ b/lib/export/export_payments.rb @@ -68,7 +68,7 @@ module ExportPayments export.exception = e.to_s export.ended = Time.now export.save! - ExportMailer.delay.export_payments_failed_notification(export) if user + ExportPaymentsFailedJob.perform_later(export) if user raise e end raise e diff --git a/lib/job_types/export_payment_failed_job.rb b/lib/job_types/export_payment_failed_job.rb deleted file mode 100644 index 991cace8..00000000 --- a/lib/job_types/export_payment_failed_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 ExportPaymentFailedJob < EmailJob - attr_reader :export - - def initialize(export) - @export = export - end - - def perform - ExportMailer.export_payments_failed_notification(export).deliver - end - end -end diff --git a/spec/lib/job_types/export_payment_failed_job_spec.rb b/spec/lib/job_types/export_payment_failed_job_spec.rb deleted file mode 100644 index c18b1070..00000000 --- a/spec/lib/job_types/export_payment_failed_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::ExportPaymentFailedJob do - describe '.perform' do - it 'calls the correct active mailer' do - expect(ExportMailer).to receive(:export_payments_failed_notification).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer } - - job = JobTypes::ExportPaymentFailedJob.new(1) - job.perform - end - end -end