Job::InviteUser -> Job::InviteUserByEmail
This commit is contained in:
parent
5c5e450a1e
commit
3392f11b64
3 changed files with 25 additions and 2 deletions
|
|
@ -23,7 +23,7 @@ class InvitationsController < Devise::InvitationsController
|
|||
|
||||
good_emails, bad_emails = emails.partition{|e| e.try(:match, Devise.email_regexp)}
|
||||
|
||||
good_emails.each{|e| Resque.enqueue(Job::InviteUser, current_user.id, e, aspect, message)}
|
||||
good_emails.each{|e| Resque.enqueue(Job::InviteUserByEmail, current_user.id, e, aspect, message)}
|
||||
|
||||
if bad_emails.any?
|
||||
flash[:error] = I18n.t('invitations.create.sent') + good_emails.join(', ') + " "+ I18n.t('invitations.create.rejected') + bad_emails.join(', ')
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
|
||||
module Job
|
||||
class InviteUser < Base
|
||||
class InviteUserByEmail < Base
|
||||
@queue = :mail
|
||||
def self.perform_delegate(sender_id, email, aspect_id, invite_message)
|
||||
user = User.find(sender_id)
|
||||
23
spec/models/jobs/invite_user_by_email_spec.rb
Normal file
23
spec/models/jobs/invite_user_by_email_spec.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Job::InviteUserByEmail do
|
||||
before do
|
||||
@sender = alice
|
||||
@email = 'bob@bob.com'
|
||||
@aspect_id = alice.aspects.first.id
|
||||
@message = 'invite message'
|
||||
|
||||
User.stub(:find){ |id|
|
||||
if id == @sender.id
|
||||
@sender
|
||||
else
|
||||
nil
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
it 'calls invite_user with email param' do
|
||||
@sender.should_receive(:invite_user).with(@aspect_id, 'email', @email, @message)
|
||||
Job::InviteUserByEmail.perform(@sender.id, @email, @aspect_id, @message)
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue