add tests for object_should_be_processed_as_public? and delegegated public to the parent of relayable objects
This commit is contained in:
parent
01f7625649
commit
6c414d8562
4 changed files with 21 additions and 2 deletions
|
|
@ -76,4 +76,5 @@ class Comment < ActiveRecord::Base
|
|||
def parent= parent
|
||||
self.post = parent
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ module Diaspora
|
|||
|
||||
validates_associated :parent
|
||||
validates :author, :presence => true
|
||||
|
||||
delegate :public?, :to => :parent
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ class Postzord::Dispatcher
|
|||
def self.object_should_be_processed_as_public?(object)
|
||||
if object.respond_to?(:public?) && object.public?
|
||||
true
|
||||
elsif object.respond_to?(:relayable?) && object.parent.respond_to?(:public?) && object.parent.public?
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
|
|
|
|||
|
|
@ -256,6 +256,24 @@ describe Postzord::Dispatcher do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#object_should_be_processed_as_public?' do
|
||||
it 'returns true with a comment on a public post' do
|
||||
f = Factory(:comment, :post => Factory(:status_message, :public => true))
|
||||
Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_true
|
||||
end
|
||||
|
||||
it 'returns false with a comment on a private post' do
|
||||
f = Factory(:comment, :post => Factory(:status_message, :public => false))
|
||||
Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_false
|
||||
end
|
||||
|
||||
it 'returns true with a like on a comment on a private post' do
|
||||
f = Factory(:like, :target => Factory(:comment, :post => Factory(:status_message, :public => true)))
|
||||
Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe '#deliver_to_services' do
|
||||
before do
|
||||
alice.aspects.create(:name => "whatever")
|
||||
|
|
|
|||
Loading…
Reference in a new issue