scoped invite_user_by_email job into Mail module
This commit is contained in:
parent
78aa6d0943
commit
669cd8578e
4 changed files with 19 additions and 17 deletions
|
|
@ -38,7 +38,7 @@ class InvitationsController < Devise::InvitationsController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
good_emails.each{|e| Resque.enqueue(Job::InviteUserByEmail, current_user.id, e, aspect, message)}
|
good_emails.each{|e| Resque.enqueue(Job::Mail::InviteUserByEmail, current_user.id, e, aspect, message)}
|
||||||
|
|
||||||
if bad_emails.any?
|
if bad_emails.any?
|
||||||
flash[:error] = I18n.t('invitations.create.sent') + good_emails.join(', ') + " "+ I18n.t('invitations.create.rejected') + bad_emails.join(', ')
|
flash[:error] = I18n.t('invitations.create.sent') + good_emails.join(', ') + " "+ I18n.t('invitations.create.rejected') + bad_emails.join(', ')
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
# Copyright (c) 2010, Diaspora Inc. This file is
|
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
|
||||||
# the COPYRIGHT file.
|
|
||||||
|
|
||||||
|
|
||||||
module Job
|
|
||||||
class InviteUserByEmail < Base
|
|
||||||
@queue = :mail
|
|
||||||
def self.perform(sender_id, email, aspect_id, invite_message)
|
|
||||||
user = User.find(sender_id)
|
|
||||||
user.invite_user(aspect_id, 'email', email, invite_message)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
16
app/models/job/mail/invite_user_by_email.rb
Normal file
16
app/models/job/mail/invite_user_by_email.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
|
||||||
|
module Job
|
||||||
|
module Mail
|
||||||
|
class InviteUserByEmail < Base
|
||||||
|
@queue = :mail
|
||||||
|
def self.perform(sender_id, email, aspect_id, invite_message)
|
||||||
|
user = User.find(sender_id)
|
||||||
|
user.invite_user(aspect_id, 'email', email, invite_message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Job::InviteUserByEmail do
|
describe Job::Mail::InviteUserByEmail do
|
||||||
before do
|
before do
|
||||||
@sender = alice
|
@sender = alice
|
||||||
@email = 'bob@bob.com'
|
@email = 'bob@bob.com'
|
||||||
|
|
@ -18,6 +18,6 @@ describe Job::InviteUserByEmail do
|
||||||
|
|
||||||
it 'calls invite_user with email param' do
|
it 'calls invite_user with email param' do
|
||||||
@sender.should_receive(:invite_user).with(@aspect_id, 'email', @email, @message)
|
@sender.should_receive(:invite_user).with(@aspect_id, 'email', @email, @message)
|
||||||
Job::InviteUserByEmail.perform(@sender.id, @email, @aspect_id, @message)
|
Job::Mail::InviteUserByEmail.perform(@sender.id, @email, @aspect_id, @message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Loading…
Reference in a new issue