Add ImportCompletedJob
This commit is contained in:
parent
2bceb3389c
commit
c29bd50fc2
4 changed files with 8 additions and 32 deletions
7
app/jobs/import_completed_job.rb
Normal file
7
app/jobs/import_completed_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class ImportCompletedJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(import)
|
||||||
|
ImportMailer.import_completed_notification(import.id).deliver_now
|
||||||
|
end
|
||||||
|
end
|
|
@ -164,7 +164,7 @@ module InsertImport
|
||||||
.returning('*')
|
.returning('*')
|
||||||
.execute.first
|
.execute.first
|
||||||
InsertFullContactInfos.enqueue(supporter_ids) if supporter_ids.any?
|
InsertFullContactInfos.enqueue(supporter_ids) if supporter_ids.any?
|
||||||
ImportMailer.delay.import_completed_notification(import['id'])
|
ImportCompletedJob.perform_later(Import.find(import['id']))
|
||||||
import
|
import
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
|
|
@ -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
|
|
Loading…
Reference in a new issue