adding job for posting to services
This commit is contained in:
parent
1d5b6fa675
commit
5818227904
2 changed files with 32 additions and 0 deletions
16
app/models/jobs/post_to_service.rb
Normal file
16
app/models/jobs/post_to_service.rb
Normal 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
|
||||||
16
spec/models/jobs/post_to_service_spec.rb
Normal file
16
spec/models/jobs/post_to_service_spec.rb
Normal 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
|
||||||
|
|
||||||
Loading…
Reference in a new issue