Add ExportSupportersFailedJob
This commit is contained in:
parent
bedce11511
commit
9b501c4509
5 changed files with 10 additions and 32 deletions
7
app/jobs/export_supporters_failed_job.rb
Normal file
7
app/jobs/export_supporters_failed_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class ExportSupportersFailedJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(export)
|
||||
ExportMailer.export_supporters_failed_notification(export).deliver_now
|
||||
end
|
||||
end
|
|
@ -65,7 +65,7 @@ module ExportSupporters
|
|||
export.exception = e.to_s
|
||||
export.ended = Time.now
|
||||
export.save!
|
||||
EmailJobQueue.queue(JobTypes::ExportSupportersFailedJob, export) if user
|
||||
ExportSupportersFailedJob.perform_later(export) if user
|
||||
raise e
|
||||
end
|
||||
raise e
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module JobTypes
|
||||
class ExportSupportersFailedJob < EmailJob
|
||||
attr_reader :export
|
||||
|
||||
def initialize(export)
|
||||
@export = export
|
||||
end
|
||||
|
||||
def perform
|
||||
ExportMailer.export_supporters_failed_notification(@export).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -150,9 +150,9 @@ describe ExportSupporters do
|
|||
it 'handles exception in upload properly' do
|
||||
Timecop.freeze(2020, 4, 5) do
|
||||
@export = force_create(:export, user: @user)
|
||||
expect_email_queued.with(JobTypes::ExportSupportersFailedJob, @export)
|
||||
CHUNKED_UPLOADER.raise_error
|
||||
Timecop.freeze(2020, 4, 6) do
|
||||
expect {
|
||||
expect { ExportSupporters.run_export(@nonprofit.id, {}.to_json, @user.id, @export.id) }.to(raise_error do |error|
|
||||
expect(error).to be_a StandardError
|
||||
expect(error.message).to eq TestChunkedUploader::TEST_ERROR_MESSAGE
|
||||
|
@ -163,6 +163,7 @@ describe ExportSupporters do
|
|||
expect(@export.ended).to eq Time.now
|
||||
expect(@export.updated_at).to eq Time.now
|
||||
end)
|
||||
}.to have_enqueued_job(ExportSupportersFailedJob).with(@export)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper.rb'
|
||||
|
||||
describe JobTypes::ExportSupportersFailedJob do
|
||||
describe '.perform' do
|
||||
it 'calls the correct active mailer' do
|
||||
input = 1
|
||||
expect(ExportMailer).to receive(:export_supporters_failed_notification).with(input).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
||||
|
||||
job = JobTypes::ExportSupportersFailedJob.new(input)
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue