diff --git a/app/jobs/recurring_donations_export_create_job.rb b/app/jobs/recurring_donations_export_create_job.rb new file mode 100644 index 00000000..d66558d2 --- /dev/null +++ b/app/jobs/recurring_donations_export_create_job.rb @@ -0,0 +1,7 @@ +class RecurringDonationsExportCreateJob < ApplicationJob + queue_as :default + + def perform(*args) + ExportRecurringDonations.run_export(*args) + end +end diff --git a/lib/export/export_recurring_donations.rb b/lib/export/export_recurring_donations.rb index 788c2d59..68d1c5f5 100644 --- a/lib/export/export_recurring_donations.rb +++ b/lib/export/export_recurring_donations.rb @@ -20,7 +20,7 @@ module ExportRecurringDonations e = Export.create(nonprofit: npo, user: user, status: :queued, export_type: 'ExportRecurringDonations', parameters: params.to_json) - DelayedJobHelper.enqueue_job(ExportRecurringDonations, :run_export, [npo_id, params.to_json, user_id, e.id]) + RecurringDonationsExportCreateJob.perform_later(npo_id, params.to_json, user_id, e.id) end def self.run_export(npo_id, params, user_id, export_id) diff --git a/spec/lib/export/export_recurring_donations_spec.rb b/spec/lib/export/export_recurring_donations_spec.rb index f2cfa946..95007d38 100644 --- a/spec/lib/export/export_recurring_donations_spec.rb +++ b/spec/lib/export/export_recurring_donations_spec.rb @@ -53,16 +53,11 @@ describe ExportRecurringDonations do it 'creates an export object and schedules job' do Timecop.freeze(2020, 4, 5) do - stub_const('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(ExportRecurringDonations, :run_export, [@nonprofit.id, params.to_json, @user.id, e.id]) # add the enqueue - e - } - + expect { ExportRecurringDonations.initiate_export(@nonprofit.id, params, @user.id) + }.to have_enqueued_job(RecurringDonationExportCreateJob) export = Export.first expected_export = { id: export.id, user_id: @user.id,