Add PaymentExportCreateJob
This commit is contained in:
parent
e073b9a7d0
commit
bc959425c5
3 changed files with 12 additions and 10 deletions
7
app/jobs/payment_export_create_job.rb
Normal file
7
app/jobs/payment_export_create_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class PaymentExportCreateJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(npo_id, params, user_id, export_id)
|
||||
ExportPayments.run_export(npo_id, params, user_id, export_id)
|
||||
end
|
||||
end
|
|
@ -20,7 +20,7 @@ module ExportPayments
|
|||
|
||||
e = Export.create(nonprofit: npo, user: user, status: :queued, export_type: 'ExportPayments', parameters: params.to_json)
|
||||
|
||||
DelayedJobHelper.enqueue_job(ExportPayments, :run_export, [npo_id, params.to_json, user_id, e.id])
|
||||
PaymentExportCreateJob.perform_later(npo_id, params.to_json, user_id, e.id)
|
||||
end
|
||||
|
||||
def self.run_export(npo_id, params, user_id, export_id)
|
||||
|
|
|
@ -60,16 +60,11 @@ describe ExportPayments do
|
|||
|
||||
it 'creates an export object and schedules job' do
|
||||
Timecop.freeze(2020, 4, 5) do
|
||||
stub_const('DelayedJobHelper', double('delayed'))
|
||||
params = { param1: 'pp' }.with_indifferent_access
|
||||
expect{
|
||||
ExportPayments.initiate_export(nonprofit.id, params, user.id)
|
||||
}.to have_enqueued_job(PaymentExportCreateJob)
|
||||
|
||||
expect(Export).to receive(:create).and_wrap_original { |m, *args|
|
||||
e = m.call(*args) # get original create
|
||||
expect(DelayedJobHelper).to receive(:enqueue_job).with(ExportPayments, :run_export, [nonprofit.id, params.to_json, user.id, e.id]) # add the enqueue
|
||||
e
|
||||
}
|
||||
|
||||
ExportPayments.initiate_export(nonprofit.id, params, user.id)
|
||||
export = Export.first
|
||||
expected_export = { id: export.id,
|
||||
user_id: user.id,
|
||||
|
|
Loading…
Reference in a new issue