fix construct_shareable_from_others_query to only include posts from contacts within your aspects

This commit is contained in:
danielgrippi 2011-11-07 10:52:12 -08:00
parent 1d0109d4cb
commit fd76cfd4c5
2 changed files with 5 additions and 4 deletions

View file

@ -64,7 +64,7 @@ module Diaspora
end
def construct_shareable_from_others_query(opts)
conditions = {:pending => false, :share_visibilities => {:hidden => opts[:hidden]}, :contacts => {:user_id => self.id} }
conditions = {:pending => false, :share_visibilities => {:hidden => opts[:hidden]}, :contacts => {:user_id => self.id, :receiving => true} }
conditions[:type] = opts[:type] if opts.has_key?(:type)
query = opts[:klass].joins(:contacts).where(conditions)

View file

@ -34,9 +34,10 @@ describe User do
alice.visible_shareable_ids(Post).should include(eves_public_post.id)
end
it "contains non-public posts from people who are following you" do
bobs_post = bob.post(:status_message, :text => "hello", :to => @bobs_aspect.id)
alice.visible_shareable_ids(Post).should include(bobs_post.id)
it "does not contain non-public posts from people who are following you" do
eve.share_with(alice.person, @eves_aspect)
eves_post = eve.post(:status_message, :text => "hello", :to => @eves_aspect.id)
alice.visible_shareable_ids(Post).should_not include(eves_post.id)
end
it "does not contain non-public posts from aspects you're not in" do