tests for post to services resque job

This commit is contained in:
maxwell 2010-12-09 16:16:29 -08:00
parent d81aa7dfe1
commit bf56364019
2 changed files with 7 additions and 5 deletions

View file

@ -153,11 +153,11 @@ class User
Rails.logger.info("event=dispatch user=#{diaspora_handle} post=#{post.id.to_s}")
push_to_aspects(post, aspects_from_ids(aspect_ids))
post_to_services(post, opts[:url])
Resque.enqueue(Jobs::PostToServices, self.id, post.id, opts[:url]) if post.public
end
def post_to_services(post, url)
if post.public && post.respond_to?(:message)
if post.respond_to?(:message)
self.services.each do |service|
service.post(post, url)
end

View file

@ -74,7 +74,8 @@ describe User do
describe '#post_to_services' do
it 'only iterates through services if the post is public' do
user.should_receive(:services).and_return([])
user.post(:status_message, :message => "foo", :public => true, :to => user.aspects.first.id)
post = user.build_post(:status_message, :message => "foo", :public => true, :to => user.aspects.first.id)
user.post_to_services(post, "dfds")
end
end
@ -98,8 +99,9 @@ describe User do
}
end
it "calls post_to_services" do
user.should_receive(:post_to_services)
it "calls post_to_services if status is public" do
Resque.should_receive(:enqueue).with(Jobs::PostToServices, anything, anything, anything)
status.public = true
user.dispatch_post(status, :to => "all")
end