Add SupporterNotesExportCreateJob

This commit is contained in:
Eric Schultz 2019-11-07 17:19:14 -06:00
parent bc959425c5
commit 016e69283c
3 changed files with 12 additions and 9 deletions

View file

@ -0,0 +1,7 @@
class SupporterNotesExportCreateJob < ApplicationJob
queue_as :default
def perform(npo_id, params, user_id, export_id)
ExportSupporterNotes.run_export(npo_id, params, user_id, export_id)
end
end

View file

@ -19,7 +19,7 @@ module ExportSupporterNotes
e = Export.create(nonprofit: npo, user: user, status: :queued, export_type: 'ExportSupporterNotes', parameters: params.to_json)
DelayedJobHelper.enqueue_job(ExportSupporterNotes, :run_export, [npo_id, params.to_json, user_id, e.id])
SupporterNotesExportCreateJob.perform_later(npo_id, params.to_json, user_id, e.id)
end
def self.run_export(npo_id, params, user_id, export_id)

View file

@ -80,16 +80,12 @@ describe ExportSupporterNotes do
it 'creates an export object and schedules job' do
Timecop.freeze(2020, 4, 5) do
DelayedJobHelper = double('delayed')
params = { param1: 'pp', root_url: 'https://localhost:8080' }.with_indifferent_access
expect(Export).to receive(:create).and_wrap_original { |m, *args|
e = m.call(*args) # get original create
expect(DelayedJobHelper).to receive(:enqueue_job).with(ExportSupporterNotes, :run_export, [nonprofit.id, params.to_json, user.id, e.id]) # add the enqueue
e
}
ExportSupporterNotes.initiate_export(nonprofit.id, params, user.id)
expect{
ExportSupporterNotes.initiate_export(nonprofit.id, params, user.id)
}.to have_enqueued_job(SupporterNotesExportCreateJob)
export = Export.first
expected_export = { id: export.id,
user_id: user.id,