Add UserInviteCreateJob

This commit is contained in:
Eric Schultz 2019-11-07 13:33:17 -06:00
parent b295bcfa65
commit 00e9cb972d
4 changed files with 8 additions and 33 deletions

View 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

View file

@ -49,7 +49,7 @@ end
if user.confirmed? if user.confirmed?
RoleAddedJob.perform_later role RoleAddedJob.perform_later role
else else
NonprofitAdminMailer.delay.new_invite(role, user.make_confirmation_token!) UserInviteCreateJob.perform_later role, user.make_confirmation_token!
end end
role role
end end

View file

@ -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

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::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