Add PayoutPendingJob

This commit is contained in:
Eric Schultz 2019-11-07 13:00:10 -06:00
parent e05466d0c6
commit 94398f8bdf
5 changed files with 8 additions and 33 deletions

View file

@ -0,0 +1,7 @@
class PayoutPendingJob < ApplicationJob
queue_as :default
def perform(payout)
NonprofitMailer.pending_payout_notification(payout.id).deliver_now
end
end

View file

@ -69,7 +69,7 @@ module InsertPayout
).first
# Create PaymentPayout records linking all the payments to the payout
pps = Psql.execute(Qexpr.new.insert('payment_payouts', payment_ids.map { |id| { payment_id: id.to_i } }, common_data: { payout_id: payout['id'].to_i }))
NonprofitMailer.delay.pending_payout_notification(payout['id'].to_i)
PayoutPendingJob.perform_later(Payout.find(payout['id'].to_i))
return payout
end
rescue Stripe::StripeError => e

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 NonprofitPendingPayoutJob < EmailJob
attr_reader :payout_id
def initialize(payout_id)
@payout_id = payout_id
end
def perform
NonprofitMailer.pending_payout_notification(@payout_id).deliver
end
end
end

View file

@ -34,7 +34,6 @@ module UpdatePayouts
payout.failure_message = failure_message
payout.save!
# NonprofitMailer.delay.pending_payout_notification(payout['id'].to_i)
payout
end
end

View file

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