stubbing out the hub publish method

This commit is contained in:
maxwell 2010-10-29 12:09:10 -07:00
parent 47a9b2d189
commit c6fbcd28f7
4 changed files with 11 additions and 3 deletions

View file

@ -1,4 +1,6 @@
class Notifier < ActionMailer::Base class Notifier < ActionMailer::Base
include Magent::Async
default :from => "no-reply@joindiaspora.com" default :from => "no-reply@joindiaspora.com"
ATTACHMENT = File.read("#{Rails.root}/public/images/diaspora_caps.png") ATTACHMENT = File.read("#{Rails.root}/public/images/diaspora_caps.png")

View file

@ -72,7 +72,7 @@ module Diaspora
activate_friend(friend_request.person, destination_aspect) activate_friend(friend_request.person, destination_aspect)
Rails.logger.info("#{self.real_name}'s friend request has been accepted") Rails.logger.info("#{self.real_name}'s friend request has been accepted")
friend_request.destroy friend_request.destroy
Notifier.request_accepted(self, friend_request.person, destination_aspect).deliver Notifier.async.request_accepted(self, friend_request.person, destination_aspect).deliver.commit(1)
#this is a new friend request #this is a new friend request
elsif !from_me elsif !from_me
@ -80,7 +80,7 @@ module Diaspora
self.save self.save
Rails.logger.info("#{self.real_name} has received a friend request") Rails.logger.info("#{self.real_name} has received a friend request")
friend_request.save friend_request.save
Notifier.new_request(self, friend_request.person).deliver Notifier.async.new_request(self, friend_request.person).deliver.commit(1)
else else
Rails.logger.info("unsolicited friend request: #{friend_request.to_json}") Rails.logger.info("unsolicited friend request: #{friend_request.to_json}")
end end

View file

@ -65,7 +65,6 @@ describe MessageHandler do
end end
describe 'POST messages' do describe 'POST messages' do
it 'should be able to add a post message to the queue' do it 'should be able to add a post message to the queue' do
EventMachine.run { EventMachine.run {
@handler.size.should ==0 @handler.size.should ==0
@ -103,6 +102,9 @@ describe MessageHandler do
end end
describe "Hub publish" do describe "Hub publish" do
before do
EventMachine::PubSubHubbub.stub(:new).and_return(:success)
end
it 'should correctly queue up a pubsubhubbub publish request' do it 'should correctly queue up a pubsubhubbub publish request' do
destination = "http://identi.ca/hub/" destination = "http://identi.ca/hub/"
feed_location = "http://google.com/" feed_location = "http://google.com/"

View file

@ -59,6 +59,10 @@ class FakeHttpRequest
self self
end end
def publish(opts = nil)
self
end
def callback(&b) def callback(&b)
b.call if @callback == :success b.call if @callback == :success
end end