don't dispatch locally on comments if you're the post owner
This commit is contained in:
parent
d040de541a
commit
716899f919
3 changed files with 21 additions and 14 deletions
|
|
@ -28,7 +28,10 @@ class Postzord::Dispatch
|
||||||
self.socket_and_notify_users(local_users)
|
self.socket_and_notify_users(local_users)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.deliver_to_local(local_people)
|
unless @object.is_a?(Comment) && @sender.owns?(@object.post)
|
||||||
|
self.deliver_to_local(local_people)
|
||||||
|
end
|
||||||
|
|
||||||
self.deliver_to_remote(remote_people)
|
self.deliver_to_remote(remote_people)
|
||||||
end
|
end
|
||||||
self.deliver_to_services(opts[:url])
|
self.deliver_to_services(opts[:url])
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,6 @@ describe 'a user receives a post' do
|
||||||
|
|
||||||
receive_with_zord(@user2, @user1.person, xml)
|
receive_with_zord(@user2, @user1.person, xml)
|
||||||
receive_with_zord(@user3, @user1.person, xml)
|
receive_with_zord(@user3, @user1.person, xml)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not raise a `Mysql2::Error: Duplicate entry...` exception on save' do
|
it 'does not raise a `Mysql2::Error: Duplicate entry...` exception on save' do
|
||||||
|
|
@ -227,14 +226,6 @@ describe 'a user receives a post' do
|
||||||
receive_with_zord(@user1, @user2.person, @xml)
|
receive_with_zord(@user1, @user2.person, @xml)
|
||||||
}.should_not raise_exception
|
}.should_not raise_exception
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should dispatch to the remote user' do
|
|
||||||
pending
|
|
||||||
Postzord::Receiver.should_receive(:new).exactly(3).times
|
|
||||||
|
|
||||||
@comment = @user2.comment('tada',:on => @post)
|
|
||||||
@user2.dispatch_comment(@comment)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,23 @@ describe Postzord::Dispatch do
|
||||||
@mailman.post
|
@mailman.post
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calls deliver_to_local' do
|
context 'local recipients' do
|
||||||
@mailman.stub!(:socket_and_notify_users)
|
it 'gets called if not the post owner' do
|
||||||
@mailman.should_receive(:deliver_to_local)
|
@mailman.stub!(:socket_and_notify_users)
|
||||||
@mailman.post
|
@mailman.should_receive(:deliver_to_local)
|
||||||
|
@mailman.post
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not get called if not the post owner' do
|
||||||
|
status = @user.build_post(:status_message, :message => 'hey', :to => @user.aspects.first)
|
||||||
|
|
||||||
|
comment = @user.comment "yo", :on => status
|
||||||
|
comment.should_receive(:subscribers).and_return([@local_user.person])
|
||||||
|
mailman2 = Postzord::Dispatch.new(@user, comment)
|
||||||
|
mailman2.stub!(:socket_and_notify_users)
|
||||||
|
mailman2.should_not_receive(:deliver_to_local)
|
||||||
|
mailman2.post
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue