Commit e61cc2fd authored by zhitomirskiyi's avatar zhitomirskiyi
Browse files

made the postzord take the services in individually

parent 126925f2
......@@ -25,7 +25,9 @@ class StatusMessagesController < ApplicationController
Rails.logger.info("event=create type=status_message chars=#{params[:status_message][:message].length}")
current_user.add_to_streams(@status_message, aspects)
current_user.dispatch_post(@status_message, :url => post_url(@status_message), :services => current_user.services)
receiving_services = params[:services].map{|s| current_user.services.where(
:type => "Services::"+s.titleize).first} if params[:services]
current_user.dispatch_post(@status_message, :url => post_url(@status_message), :services => receiving_services)
if !photos.empty?
for photo in photos
was_pending = photo.pending
......
......@@ -50,7 +50,7 @@
= link_to (image_tag "social_media_logos/feed-16x16.png", :title => "RSS"), current_user.public_url
- if current_user.services
- for service in current_user.services
= image_tag "social_media_logos/#{service.provider}-16x16.png", :title => service.provider
= image_tag "social_media_logos/#{service.provider}-16x16.png", :title => service.provider, :class => "service", :id =>"#{service.provider}"
= link_to '(?)', "#question_mark_pane", :class => 'question_mark', :style=>"display:none;", :rel => 'facebox'
......
......@@ -58,10 +58,10 @@ class Postzord::Dispatch
def deliver_to_services(url, services)
if @object.respond_to?(:public) && @object.public
deliver_to_hub
if @object.respond_to?(:message)
services.each do |service|
Resque.enqueue(Job::PostToService, service.id, @object.id, url)
end
end
if @object.respond_to?(:message)
services.each do |service|
Resque.enqueue(Job::PostToService, service.id, @object.id, url)
end
end
end
......
......@@ -64,9 +64,12 @@ describe StatusMessagesController do
response.status.should == 201
end
it "dispatches the post to the user's services" do
@user1.services << Services::Facebook.new
@user1.should_receive(:dispatch_post).with(anything(),hash_including(:services => @user1.services))
it "dispatches the post to the specified services" do
s1 = Services::Facebook.new
@user1.services << s1
@user1.services << Services::Twitter.new
status_message_hash[:services] = ['facebook']
@user1.should_receive(:dispatch_post).with(anything(), hash_including(:services => [s1]))
post :create, status_message_hash
end
......
......@@ -273,7 +273,15 @@ describe Postzord::Dispatch do
Resque.stub!(:enqueue).with(Job::PublishToHub, anything)
Resque.should_receive(:enqueue).with(Job::PostToService, @s1.id, anything, anything)
mailman.post(:url => "http://joindiaspora.com/p/123", :services => [@s1, @s2])
mailman.post(:url => "http://joindiaspora.com/p/123", :services => [@s1])
end
it 'does not push to services if none are specified' do
mailman = Postzord::Dispatch.new(@user, Factory(:status_message))
Resque.stub!(:enqueue).with(Job::PublishToHub, anything)
Resque.should_not_receive(:enqueue).with(Job::PostToService, anything, anything, anything)
mailman.post(:url => "http://joindiaspora.com/p/123")
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment