diff --git a/app/jobs/user_invite_create_job.rb b/app/jobs/user_invite_create_job.rb new file mode 100644 index 00000000..13b73e32 --- /dev/null +++ b/app/jobs/user_invite_create_job.rb @@ -0,0 +1,7 @@ +class UserInviteCreateJob < ApplicationJob + queue_as :default + + def perform(role, raw_token) + NonprofitAdminMailer.new_invite(role, raw_token).deliver_now + end +end diff --git a/app/models/role.rb b/app/models/role.rb index 67108d88..5b3002db 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -49,7 +49,7 @@ end if user.confirmed? RoleAddedJob.perform_later role else - NonprofitAdminMailer.delay.new_invite(role, user.make_confirmation_token!) + UserInviteCreateJob.perform_later role, user.make_confirmation_token! end role end diff --git a/lib/job_types/nonprofit_admin_new_invite_job.rb b/lib/job_types/nonprofit_admin_new_invite_job.rb deleted file mode 100644 index dcccbfe6..00000000 --- a/lib/job_types/nonprofit_admin_new_invite_job.rb +++ /dev/null @@ -1,17 +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 NonprofitAdminNewInviteJob < EmailJob - attr_reader :role, :raw_token - - def initialize(role, raw_token) - @role = role - @raw_token = raw_token - end - - def perform - NonprofitAdminMailer.new_invite(@role, @raw_token).deliver - end - end -end diff --git a/spec/lib/job_types/nonprofit_admin_new_invite_job_spec.rb b/spec/lib/job_types/nonprofit_admin_new_invite_job_spec.rb deleted file mode 100644 index 84fb75d4..00000000 --- a/spec/lib/job_types/nonprofit_admin_new_invite_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::NonprofitAdminNewInviteJob do - describe '.perform' do - it 'calls the correct active mailer' do - expect(NonprofitAdminMailer).to receive(:new_invite).with(1, 2).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer } - - job = JobTypes::NonprofitAdminNewInviteJob.new(1, 2) - job.perform - end - end -end