test for pubsubhububb jobs
This commit is contained in:
parent
7c3c17a418
commit
153c4925d6
4 changed files with 35 additions and 4 deletions
13
app/models/jobs/publish_to_hub.rb
Normal file
13
app/models/jobs/publish_to_hub.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# 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 PublishToHub
|
||||
|
||||
require File.join(Rails.root, 'lib/pubsubhubbub')
|
||||
def self.perform(sender_public_url)
|
||||
PubSubHubbub.new(AppConfig[:pubsub_server]).publish(sender_public_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -45,7 +45,7 @@ class Postzord::Dispatch
|
|||
|
||||
def deliver_to_hub
|
||||
Rails.logger.debug("event=post_to_service type=pubsub sender_handle=#{@sender.diaspora_handle}")
|
||||
PubSubHubbub.new(AppConfig[:pubsub_server]).publish(@sender.public_url)
|
||||
Resque.enqueue(Jobs::PublishToHub, @sender.public_url)
|
||||
end
|
||||
|
||||
def deliver_to_services(url)
|
||||
|
|
|
|||
|
|
@ -124,9 +124,9 @@ describe Postzord::Dispatch do
|
|||
@zord.send(:deliver_to_services, nil)
|
||||
end
|
||||
|
||||
it 'notifies the hub' do
|
||||
@zord.should_receive(:deliver_to_hub)
|
||||
@zord.send(:deliver_to_services, nil)
|
||||
it 'queues a job to notify the hub' do
|
||||
Resque.should_receive(:enqueue).with(Jobs::PublishToHub, @user.public_url)
|
||||
@zord.send(:deliver_to_services, nil)
|
||||
end
|
||||
|
||||
it 'only pushes to services if the object is public' do
|
||||
|
|
|
|||
18
spec/models/jobs/publish_to_hub_spec.rb
Normal file
18
spec/models/jobs/publish_to_hub_spec.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Jobs::PublishToHub do
|
||||
describe '.perform' do
|
||||
it 'calls pubsubhubbub' do
|
||||
url = "http://publiczone.com/"
|
||||
m = mock()
|
||||
|
||||
m.should_receive(:publish).with(url)
|
||||
PubSubHubbub.should_receive(:new).with(AppConfig[:pubsub_server]).and_return(m)
|
||||
Jobs::PublishToHub.perform(url)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue