From c29bd50fc239dcacbc282831b91a93783a908e5c Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Thu, 7 Nov 2019 13:24:12 -0600 Subject: [PATCH] Add ImportCompletedJob --- app/jobs/import_completed_job.rb | 7 +++++++ lib/insert/insert_import.rb | 2 +- .../import_complete_notification_job.rb | 16 ---------------- .../import_complete_notification_job_spec.rb | 15 --------------- 4 files changed, 8 insertions(+), 32 deletions(-) create mode 100644 app/jobs/import_completed_job.rb delete mode 100644 lib/job_types/import_complete_notification_job.rb delete mode 100644 spec/lib/job_types/import_complete_notification_job_spec.rb diff --git a/app/jobs/import_completed_job.rb b/app/jobs/import_completed_job.rb new file mode 100644 index 00000000..b8a96102 --- /dev/null +++ b/app/jobs/import_completed_job.rb @@ -0,0 +1,7 @@ +class ImportCompletedJob < ApplicationJob + queue_as :default + + def perform(import) + ImportMailer.import_completed_notification(import.id).deliver_now + end +end diff --git a/lib/insert/insert_import.rb b/lib/insert/insert_import.rb index e7bad74e..d1c2adc7 100644 --- a/lib/insert/insert_import.rb +++ b/lib/insert/insert_import.rb @@ -164,7 +164,7 @@ module InsertImport .returning('*') .execute.first InsertFullContactInfos.enqueue(supporter_ids) if supporter_ids.any? - ImportMailer.delay.import_completed_notification(import['id']) + ImportCompletedJob.perform_later(Import.find(import['id'])) import end end diff --git a/lib/job_types/import_complete_notification_job.rb b/lib/job_types/import_complete_notification_job.rb deleted file mode 100644 index 1ae54972..00000000 --- a/lib/job_types/import_complete_notification_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 ImportCompleteNotificationJob < EmailJob - attr_reader :import_id - - def initialize(import_id) - @import_id = import_id - end - - def perform - ImportMailer.import_completed_notification(@import_id).deliver - end - end -end diff --git a/spec/lib/job_types/import_complete_notification_job_spec.rb b/spec/lib/job_types/import_complete_notification_job_spec.rb deleted file mode 100644 index 47793b74..00000000 --- a/spec/lib/job_types/import_complete_notification_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::ImportCompleteNotificationJob do - describe '.perform' do - it 'calls the correct active mailer' do - expect(ImportMailer).to receive(:import_completed_notification).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer } - - job = JobTypes::ImportCompleteNotificationJob.new(1) - job.perform - end - end -end