Create an InviteEmail worker.
This commit is contained in:
parent
30dff802d5
commit
33f858b558
3 changed files with 18 additions and 24 deletions
|
|
@ -4,14 +4,11 @@
|
|||
|
||||
module Workers
|
||||
module Mail
|
||||
class InviteUserByEmail < Base
|
||||
class InviteEmail < Base
|
||||
sidekiq_options queue: :mail
|
||||
|
||||
def perform(invite_id)
|
||||
invite = Invitation.find(invite_id)
|
||||
I18n.with_locale(invite.language) do
|
||||
invite.send!
|
||||
end
|
||||
def perform(emails, inviter_id, options={})
|
||||
EmailInviter.new(emails, User.find(inviter_id), options).send!
|
||||
end
|
||||
end
|
||||
end
|
||||
14
spec/workers/mail/invite_email_spec.rb
Normal file
14
spec/workers/mail/invite_email_spec.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Workers::Mail::InviteEmail do
|
||||
let(:emails) { ['foo@bar.com', 'baz@bar.com'] }
|
||||
let(:message) { 'get over here!' }
|
||||
let(:email_inviter) { double('EmailInviter') }
|
||||
|
||||
it 'creates a new email inviter' do
|
||||
EmailInviter.should_receive(:new).with(emails, alice, message: message)
|
||||
.and_return(email_inviter)
|
||||
email_inviter.should_receive(:send!)
|
||||
Workers::Mail::InviteEmail.new.perform(emails, alice, message: message)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Workers::Mail::InviteUserByEmail do
|
||||
before do
|
||||
@sender = alice
|
||||
@email = 'bob@bob.com'
|
||||
@aspect = alice.aspects.first
|
||||
@message = 'invite message'
|
||||
end
|
||||
|
||||
it 'calls invite_user with email param' do
|
||||
invitation = Invitation.create(:sender => @sender, :identifier => @email, :service => "email", :aspect => @aspect, :message => @message)
|
||||
invitation.should_receive(:send!)
|
||||
Invitation.stub(:find).and_return(invitation)
|
||||
Workers::Mail::InviteUserByEmail.new.perform(invitation.id)
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue