Add ExportSupporterNotesCompletedJob

This commit is contained in:
Eric Schultz 2019-11-07 13:17:06 -06:00
parent b6e11124de
commit ad2b701f69
5 changed files with 10 additions and 34 deletions

View file

@ -0,0 +1,7 @@
class ExportSupporterNotesCompletedJob < ApplicationJob
queue_as :default
def perform(export)
ExportMailer.export_supporter_notes_completed_notification(export).deliver_now
end
end

View file

@ -59,8 +59,7 @@ module ExportSupporterNotes
export.status = :completed
export.ended = Time.now
export.save!
EmailJobQueue.queue(JobTypes::ExportSupporterNotesCompletedJob, export)
ExportSupporterNotesCompletedJob.perform_later(export)
rescue StandardError => e
if export
export.status = :failed

View file

@ -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 ExportSupporterNotesCompletedJob < EmailJob
attr_reader :export
def initialize(export)
@export = export
end
def perform
ExportMailer.export_supporter_notes_completed_notification(@export).deliver
end
end
end

View file

@ -204,7 +204,9 @@ describe ExportSupporterNotes do
@export = create(:export, user: user, created_at: Time.now, updated_at: Time.now)
expect_email_queued.with(JobTypes::ExportSupporterNotesCompletedJob, @export)
Timecop.freeze(2020, 4, 6, 1, 2, 3) do
expect {
ExportSupporterNotes.run_export(nonprofit.id, { root_url: 'https://localhost:8080/' }.to_json, user.id, @export.id)
}.to have_enqueued_job(ExportSupporterNotesCompletedJob).with(@export)
@export.reload

View file

@ -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::ExportSupporterNotesCompletedJob do
describe '.perform' do
it 'calls the correct active mailer' do
input = 1
expect(ExportMailer).to receive(:export_supporter_notes_completed_notification).with(input).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
job = JobTypes::ExportSupporterNotesCompletedJob.new(1)
job.perform
end
end
end