Add VerificationFailedJob
This commit is contained in:
parent
6ce5a43735
commit
ade965ba22
4 changed files with 8 additions and 32 deletions
7
app/jobs/verification_failed_job.rb
Normal file
7
app/jobs/verification_failed_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class VerificationFailedJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(nonprofit)
|
||||
NonprofitMailer.failed_verification_notice(onprofit).deliver_now
|
||||
end
|
||||
end
|
|
@ -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 NonprofitFailedVerificationJob < EmailJob
|
||||
attr_reader :np
|
||||
|
||||
def initialize(np)
|
||||
@np = np
|
||||
end
|
||||
|
||||
def perform
|
||||
NonprofitMailer.failed_verification_notice(@np).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -60,7 +60,7 @@ module ScheduledJobs
|
|||
acct = Stripe::Account.retrieve(np.stripe_account_id)
|
||||
verified = acct.transfers_enabled && acct.verification.fields_needed.count == 0
|
||||
np.verification_status = verified ? 'verified' : np.verification_status
|
||||
NonprofitMailer.failed_verification_notice(np).deliver if np.verification_status != 'verified'
|
||||
VerificationFailedJob.perform_later(np) if np.verification_status != 'verified'
|
||||
NonprofitMailer.successful_verification_notice(np).deliver if np.verification_status == 'verified'
|
||||
np.save
|
||||
"Status updated for NP #{np.id} as '#{np.verification_status}'"
|
||||
|
|
|
@ -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::NonprofitFailedVerificationJob do
|
||||
describe '.perform' do
|
||||
it 'calls the correct active mailer' do
|
||||
expect(NonprofitMailer).to receive(:failed_verification_notice).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
||||
|
||||
job = JobTypes::NonprofitFailedVerificationJob.new(1)
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue