Add ExportSupportersCompletedJob
This commit is contained in:
parent
b2aaf30a14
commit
bedce11511
4 changed files with 11 additions and 17 deletions
7
app/jobs/export_supporters_completed_job.rb
Normal file
7
app/jobs/export_supporters_completed_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class ExportSupportersCompletedJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(export)
|
||||
ExportMailer.export_supporters_completed_notification(export).deliver_now
|
||||
end
|
||||
end
|
|
@ -58,7 +58,7 @@ module ExportSupporters
|
|||
export.ended = Time.now
|
||||
export.save!
|
||||
|
||||
EmailJobQueue.queue(JobTypes::ExportSupportersCompletedJob, export)
|
||||
ExportSupportersCompletedJob.perform_later export
|
||||
rescue StandardError => e
|
||||
if export
|
||||
export.status = :failed
|
||||
|
|
|
@ -172,7 +172,9 @@ describe ExportSupporters do
|
|||
@export = create(:export, user: @user, created_at: Time.now, updated_at: Time.now)
|
||||
expect_email_queued.with(JobTypes::ExportSupportersCompletedJob, @export)
|
||||
Timecop.freeze(2020, 4, 6, 1, 2, 3) do
|
||||
expect {
|
||||
ExportSupporters.run_export(@nonprofit.id, { root_url: 'https://localhost:8080/' }.to_json, @user.id, @export.id)
|
||||
}.to have_enqueued_job(ExportSupportersCompletedJob).with(@export)
|
||||
|
||||
@export.reload
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper.rb'
|
||||
|
||||
describe JobTypes::ExportSupportersCompletedJob do
|
||||
describe '.perform' do
|
||||
it 'calls the correct active mailer' do
|
||||
input = 1
|
||||
expect(ExportMailer).to receive(:export_supporters_completed_notification).with(input).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
||||
|
||||
job = JobTypes::ExportSupportersCompletedJob.new(input)
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue