added specs for push_to_services, also rename the socket webfinger job spec because since it did not end with '_spec' it was not getting run

This commit is contained in:
maxwell 2010-12-09 15:25:07 -08:00
parent 9d37b2a749
commit d81aa7dfe1
5 changed files with 28 additions and 3 deletions

View file

@ -1,6 +1,7 @@
module Jobs
class HttpPost
class HttpPost
@queue = :http
def self.perform(url, body, tries_remaining)
begin
RestClient.post(url, :xml => body){ |response, request, result, &block|

View file

@ -0,0 +1,11 @@
module Jobs
class PostToServices
@queue = :http
def self.perform(user_id, post_id, url)
user = User.find_by_id(user_id)
post = Post.find_by_id(post_id)
user.post_to_services(post, url)
end
end
end

View file

@ -166,7 +166,6 @@ class User
def post_to_hub(post)
Rails.logger.debug("event=post_to_service type=pubsub sender_handle=#{self.diaspora_handle}")
EventMachine::PubSubHubbub.new(APP_CONFIG[:pubsub_server]).publish self.public_url
end

View file

@ -0,0 +1,14 @@
require 'spec_helper'
describe Jobs::PostToServices do
it 'calls post to services from the given user with given post' do
user = make_user
aspect = user.aspects.create(:name => "yeah")
post = user.post(:status_message, :message => 'foo', :to => aspect.id)
User.stub!(:find_by_id).with(user.id.to_s).and_return(user)
user.stub!(:services).and_return([])
user.should_receive(:post_to_services)
url = "foobar"
Jobs::PostToServices.perform(user.id.to_s, post.id.to_s, url)
end
end

View file

@ -40,7 +40,7 @@ describe Jobs::SocketWebfinger do
Webfinger.stub(:new).and_return(finger)
finger.stub(:fetch).and_raise(Webfinger::WebfingerFailedError)
opts = {:class => 'people', :status => 'fail', :query => @account, :response => I18n.t('people.webfinger.fail')}.to_json
opts = {:class => 'people', :status => 'fail', :query => @account, :response => I18n.t('people.webfinger.fail', :handle => @account )}.to_json
Diaspora::WebSocket.should_receive(:queue_to_user).with(@user.id, opts)
Jobs::SocketWebfinger.perform(@user.id, @account)