From b6e11124def0e99dace12c12093d4e3ff9062344 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Thu, 7 Nov 2019 13:12:04 -0600 Subject: [PATCH] Add ExportRecurringDonationsFailedJob --- .../export_recurring_donations_failed_job.rb | 7 +++++++ lib/export/export_recurring_donations.rb | 2 +- .../export_recurring_donations_failed_job.rb | 16 ---------------- ...export_recurring_donations_failed_job_spec.rb | 15 --------------- 4 files changed, 8 insertions(+), 32 deletions(-) create mode 100644 app/jobs/export_recurring_donations_failed_job.rb delete mode 100644 lib/job_types/export_recurring_donations_failed_job.rb delete mode 100644 spec/lib/job_types/export_recurring_donations_failed_job_spec.rb diff --git a/app/jobs/export_recurring_donations_failed_job.rb b/app/jobs/export_recurring_donations_failed_job.rb new file mode 100644 index 00000000..37738745 --- /dev/null +++ b/app/jobs/export_recurring_donations_failed_job.rb @@ -0,0 +1,7 @@ +class ExportRecurringDonationsFailedJob < ApplicationJob + queue_as :default + + def perform(export) + ExportMailer.export_recurring_donations_failed_notification(export).deliver_now + end +end diff --git a/lib/export/export_recurring_donations.rb b/lib/export/export_recurring_donations.rb index b70df08f..788c2d59 100644 --- a/lib/export/export_recurring_donations.rb +++ b/lib/export/export_recurring_donations.rb @@ -69,7 +69,7 @@ module ExportRecurringDonations export.ended = Time.now export.save! if user - ExportMailer.delay.export_recurring_donations_failed_notification(export) + ExportRecurringDonationsFailedJob.perform_later(export) end raise e end diff --git a/lib/job_types/export_recurring_donations_failed_job.rb b/lib/job_types/export_recurring_donations_failed_job.rb deleted file mode 100644 index 705fbfa1..00000000 --- a/lib/job_types/export_recurring_donations_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 ExportRecurringDonationsFailedJob < EmailJob - attr_reader :export - - def initialize(export) - @export = export - end - - def perform - ExportMailer.export_recurring_donations_failed_notification(@export).deliver - end - end -end diff --git a/spec/lib/job_types/export_recurring_donations_failed_job_spec.rb b/spec/lib/job_types/export_recurring_donations_failed_job_spec.rb deleted file mode 100644 index 68bf2863..00000000 --- a/spec/lib/job_types/export_recurring_donations_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::ExportRecurringDonationsFailedJob do - describe '.perform' do - it 'calls the correct active mailer' do - expect(ExportMailer).to receive(:export_recurring_donations_failed_notification).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer } - - job = JobTypes::ExportRecurringDonationsFailedJob.new(1) - job.perform - end - end -end