Add BankAccountCreateJob
This commit is contained in:
parent
7c9524ee21
commit
283ebc553b
5 changed files with 9 additions and 33 deletions
|
@ -58,7 +58,7 @@ module Nonprofits
|
|||
def resend_confirmation
|
||||
npo = current_nonprofit
|
||||
ba = npo.bank_account
|
||||
NonprofitMailer.delay.new_bank_account_notification(ba) if ba.valid?
|
||||
BankAccountCreateJob.perform_later(ba) if ba.valid?
|
||||
respond_to { |format| format.json { render json: {} } }
|
||||
end
|
||||
|
||||
|
|
7
app/jobs/bank_account_create_job.rb
Normal file
7
app/jobs/bank_account_create_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class BankAccountCreateJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(bank_account)
|
||||
NonprofitMailer.new_bank_account_notification(bank_account).deliver
|
||||
end
|
||||
end
|
|
@ -53,7 +53,7 @@ module InsertBankAccount
|
|||
pending_verification: true
|
||||
)
|
||||
|
||||
NonprofitMailer.delay.new_bank_account_notification(bank_account)
|
||||
BankAccountCreateJob.perform_later(bank_account)
|
||||
return bank_account
|
||||
rescue Stripe::StripeError => error
|
||||
params[:failure_message] = "Failed to connect the bank account: #{error.inspect}"
|
||||
|
|
|
@ -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 NonprofitNewBankAccountJob < EmailJob
|
||||
attr_reader :ba
|
||||
|
||||
def initialize(ba)
|
||||
@ba = ba
|
||||
end
|
||||
|
||||
def perform
|
||||
NonprofitMailer.new_bank_account_notification(@ba).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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::NonprofitNewBankAccountJob do
|
||||
describe '.perform' do
|
||||
it 'calls the correct active mailer' do
|
||||
expect(NonprofitMailer).to receive(:new_bank_account_notification).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
||||
|
||||
job = JobTypes::NonprofitNewBankAccountJob.new(1)
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue