diff --git a/app/jobs/verification_completed_job.rb b/app/jobs/verification_completed_job.rb new file mode 100644 index 00000000..9eb9eac7 --- /dev/null +++ b/app/jobs/verification_completed_job.rb @@ -0,0 +1,7 @@ +class VerificationCompletedJob < ApplicationJob + queue_as :default + + def perform(nonprofit) + NonprofitMailer.successful_verification_notice(nonprofit).deliver_now + end +end diff --git a/lib/job_types/nonprofit_successful_verification_job.rb b/lib/job_types/nonprofit_successful_verification_job.rb deleted file mode 100644 index a19109ef..00000000 --- a/lib/job_types/nonprofit_successful_verification_job.rb +++ /dev/null @@ -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 diff --git a/lib/scheduled_jobs.rb b/lib/scheduled_jobs.rb index bd51d907..e1038afa 100644 --- a/lib/scheduled_jobs.rb +++ b/lib/scheduled_jobs.rb @@ -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 diff --git a/spec/lib/job_types/nonprofit_successful_verification_job_spec.rb b/spec/lib/job_types/nonprofit_successful_verification_job_spec.rb deleted file mode 100644 index d7960da1..00000000 --- a/spec/lib/job_types/nonprofit_successful_verification_job_spec.rb +++ /dev/null @@ -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