adding job for posting to services

This commit is contained in:
maxwell 2011-01-06 13:13:09 -08:00
parent 1d5b6fa675
commit 5818227904
2 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,16 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
#
module Jobs
class PostToService
extend ResqueJobLogging
@queue = :http
def self.perform(service_id, post_id, url)
service = Service.find_by_id(service_id)
post = Post.find_by_id(post_id)
service.post(post, url)
end
end
end

View file

@ -0,0 +1,16 @@
require 'spec_helper'
describe Jobs::PostToService do
it 'calls service#post with the given service' 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)
m = mock()
url = "foobar"
m.should_receive(:post).with(anything, url)
Service.stub!(:find_by_id).and_return(m)
Jobs::PostToService.perform("123", post.id.to_s, url)
end
end