Add VerificationCompletedJob

This commit is contained in:
Eric Schultz 2019-11-07 13:54:05 -06:00
parent ade965ba22
commit 7c9524ee21
4 changed files with 8 additions and 32 deletions

View file

@ -0,0 +1,7 @@
class VerificationCompletedJob < ApplicationJob
queue_as :default
def perform(nonprofit)
NonprofitMailer.successful_verification_notice(nonprofit).deliver_now
end
end

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 NonprofitSuccessfulVerificationJob < EmailJob
attr_reader :np
def initialize(np)
@np = np
end
def perform
NonprofitMailer.successful_verification_notice(@np).deliver
end
end
end

View file

@ -61,7 +61,7 @@ module ScheduledJobs
verified = acct.transfers_enabled && acct.verification.fields_needed.count == 0
np.verification_status = verified ? 'verified' : np.verification_status
VerificationFailedJob.perform_later(np) if np.verification_status != 'verified'
NonprofitMailer.successful_verification_notice(np).deliver if np.verification_status == 'verified'
VerificationCompletedJob.perform_later(np) if np.verification_status == 'verified'
np.save
"Status updated for NP #{np.id} as '#{np.verification_status}'"
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::NonprofitSuccessfulVerificationJob do
describe '.perform' do
it 'calls the correct active mailer' do
expect(NonprofitMailer).to receive(:successful_verification_notice).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
job = JobTypes::NonprofitSuccessfulVerificationJob.new(1)
job.perform
end
end
end