not delivering to local for profiles

This commit is contained in:
zhitomirskiyi 2011-03-29 17:23:28 -07:00
parent 0aaaefeba2
commit 18ea46710b
2 changed files with 17 additions and 3 deletions

View file

@ -44,7 +44,7 @@ class Postzord::Dispatch
end
def deliver_to_local(people)
return if people.blank?
return if people.blank? || @object.is_a?(Profile)
if @object.is_a?(Post)
batch_deliver_to_local(people)
else

View file

@ -234,12 +234,26 @@ describe Postzord::Dispatch do
end
describe '#deliver_to_local' do
before do
@mailman = Postzord::Dispatch.new(@user, @sm)
end
it 'queues a batch receive' do
local_people = []
local_people << @user.person
mailman = Postzord::Dispatch.new(@user, @sm)
Resque.should_receive(:enqueue).with(Job::ReceiveLocalBatch, @sm.id, [@user.id]).once
mailman.send(:deliver_to_local, local_people)
@mailman.send(:deliver_to_local, local_people)
end
it 'returns if people are empty' do
Resque.should_not_receive(:enqueue)
@mailman.send(:deliver_to_local, [])
end
it 'returns if the object is a profile' do
@mailman.instance_variable_set(:@object, Profile.new)
Resque.should_not_receive(:enqueue)
@mailman.send(:deliver_to_local, [1])
end
end