Add ExportSupporterNotesFailedJob
This commit is contained in:
parent
ad2b701f69
commit
2bceb3389c
5 changed files with 10 additions and 34 deletions
7
app/jobs/export_supporter_notes_failed_job.rb
Normal file
7
app/jobs/export_supporter_notes_failed_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class ExportSupporterNotesFailedJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(export)
|
||||
ExportMailer.export_supporter_notes_failed_notification(export).deliver_now
|
||||
end
|
||||
end
|
|
@ -67,7 +67,7 @@ module ExportSupporterNotes
|
|||
export.ended = Time.now
|
||||
export.save!
|
||||
if user
|
||||
EmailJobQueue.queue(JobTypes::ExportSupporterNotesFailedJob, export)
|
||||
ExportSupporterNotesFailedJob.perform_later export
|
||||
end
|
||||
raise e
|
||||
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 ExportSupporterNotesFailedJob < EmailJob
|
||||
attr_reader :export
|
||||
|
||||
def initialize(export)
|
||||
@export = export
|
||||
end
|
||||
|
||||
def perform
|
||||
ExportMailer.export_supporter_notes_failed_notification(@export).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -182,9 +182,9 @@ describe ExportSupporterNotes 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::ExportSupporterNotesFailedJob, @export)
|
||||
CHUNKED_UPLOADER.raise_error
|
||||
Timecop.freeze(2020, 4, 6) do
|
||||
expect {
|
||||
expect { ExportSupporterNotes.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
|
||||
|
@ -195,6 +195,7 @@ describe ExportSupporterNotes do
|
|||
expect(@export.ended).to eq Time.now
|
||||
expect(@export.updated_at).to eq Time.now
|
||||
end)
|
||||
}.to have_enqueued_job(ExportSupporterNotesFailedJob).with(@export)
|
||||
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
|
||||
require 'rails_helper.rb'
|
||||
|
||||
describe JobTypes::ExportSupporterNotesFailedJob do
|
||||
describe '.perform' do
|
||||
it 'calls the correct active mailer' do
|
||||
input = 1
|
||||
expect(ExportMailer).to receive(:export_supporter_notes_failed_notification).with(input).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
||||
|
||||
job = JobTypes::ExportSupporterNotesFailedJob.new(1)
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue