Add RoleAddedJob
This commit is contained in:
parent
c29bd50fc2
commit
b295bcfa65
4 changed files with 8 additions and 32 deletions
7
app/jobs/role_added_job.rb
Normal file
7
app/jobs/role_added_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class RoleAddedJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(role)
|
||||
NonprofitAdminMailer.existing_invite(role).deliver_now
|
||||
end
|
||||
end
|
|
@ -47,7 +47,7 @@ end
|
|||
return role unless role.valid?
|
||||
|
||||
if user.confirmed?
|
||||
NonprofitAdminMailer.delay.existing_invite(role)
|
||||
RoleAddedJob.perform_later role
|
||||
else
|
||||
NonprofitAdminMailer.delay.new_invite(role, user.make_confirmation_token!)
|
||||
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 NonprofitAdminExistingInviteJob < EmailJob
|
||||
attr_reader :role
|
||||
|
||||
def initialize(role)
|
||||
@role = role
|
||||
end
|
||||
|
||||
def perform
|
||||
NonprofitAdminMailer.existing_invite(@role).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::NonprofitAdminExistingInviteJob do
|
||||
describe '.perform' do
|
||||
it 'calls the correct active mailer' do
|
||||
expect(NonprofitAdminMailer).to receive(:existing_invite).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
||||
|
||||
job = JobTypes::NonprofitAdminExistingInviteJob.new(1)
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue