diff --git a/lib/postzord/dispatch.rb b/lib/postzord/dispatch.rb index 5f8db8ba4..f142387d6 100644 --- a/lib/postzord/dispatch.rb +++ b/lib/postzord/dispatch.rb @@ -19,7 +19,7 @@ class Postzord::Dispatch unless @subscribers == nil remote_people, local_people = @subscribers.partition{ |person| person.owner_id.nil? } 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.deliver_to_remote(remote_people) self.deliver_to_local(local_people) @@ -53,7 +53,7 @@ class Postzord::Dispatch deliver_to_hub if @object.respond_to?(:message) @sender.services.each do |service| - service.post(@object, url) + Resque.enqueue(Jobs::PostToService, service.id, @object.id, url) end end end diff --git a/spec/lib/postzord/dispatch_spec.rb b/spec/lib/postzord/dispatch_spec.rb index b942c6622..64d3d45ed 100644 --- a/spec/lib/postzord/dispatch_spec.rb +++ b/spec/lib/postzord/dispatch_spec.rb @@ -119,12 +119,14 @@ describe Postzord::Dispatch do end 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.send(:deliver_to_services, nil) end 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) @zord.send(:deliver_to_services, nil) end