Add UserInviteCreateJob
This commit is contained in:
parent
b295bcfa65
commit
00e9cb972d
4 changed files with 8 additions and 33 deletions
7
app/jobs/user_invite_create_job.rb
Normal file
7
app/jobs/user_invite_create_job.rb
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in a new issue