if you write jobs, you should use them in you app
This commit is contained in:
parent
868cb1efc1
commit
8f1f01f0a3
2 changed files with 5 additions and 3 deletions
|
|
@ -19,7 +19,7 @@ class Postzord::Dispatch
|
||||||
unless @subscribers == nil
|
unless @subscribers == nil
|
||||||
remote_people, local_people = @subscribers.partition{ |person| person.owner_id.nil? }
|
remote_people, local_people = @subscribers.partition{ |person| person.owner_id.nil? }
|
||||||
user_ids = [*local_people].map{|x| x.owner_id }
|
user_ids = [*local_people].map{|x| x.owner_id }
|
||||||
local_users = User.all(:id.in => user_ids)
|
local_users = User.all(:id.in => user_ids, :fields => ['person_id, username, language, email'])
|
||||||
self.socket_to_users(local_users)
|
self.socket_to_users(local_users)
|
||||||
self.deliver_to_remote(remote_people)
|
self.deliver_to_remote(remote_people)
|
||||||
self.deliver_to_local(local_people)
|
self.deliver_to_local(local_people)
|
||||||
|
|
@ -53,7 +53,7 @@ class Postzord::Dispatch
|
||||||
deliver_to_hub
|
deliver_to_hub
|
||||||
if @object.respond_to?(:message)
|
if @object.respond_to?(:message)
|
||||||
@sender.services.each do |service|
|
@sender.services.each do |service|
|
||||||
service.post(@object, url)
|
Resque.enqueue(Jobs::PostToService, service.id, @object.id, url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -119,12 +119,14 @@ describe Postzord::Dispatch do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calls post for each of the users services' do
|
it 'calls post for each of the users services' do
|
||||||
@service.should_receive(:post).once
|
Resque.stub!(:enqueue).with(Jobs::PublishToHub, anything)
|
||||||
|
Resque.should_receive(:enqueue).with(Jobs::PostToService, @service.id, anything, anything).once
|
||||||
@zord.instance_variable_get(:@sender).should_receive(:services).and_return([@service])
|
@zord.instance_variable_get(:@sender).should_receive(:services).and_return([@service])
|
||||||
@zord.send(:deliver_to_services, nil)
|
@zord.send(:deliver_to_services, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'queues a job to notify the hub' do
|
it 'queues a job to notify the hub' do
|
||||||
|
Resque.stub!(:enqueue).with(Jobs::PostToService, anything, anything, anything)
|
||||||
Resque.should_receive(:enqueue).with(Jobs::PublishToHub, @user.public_url)
|
Resque.should_receive(:enqueue).with(Jobs::PublishToHub, @user.public_url)
|
||||||
@zord.send(:deliver_to_services, nil)
|
@zord.send(:deliver_to_services, nil)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue