Blow out the visible_posts specs so I can more easily see what it's doing
This commit is contained in:
parent
1363021859
commit
d1604a5bb5
1 changed files with 57 additions and 39 deletions
|
|
@ -13,16 +13,37 @@ describe User do
|
|||
end
|
||||
|
||||
describe "#visible_posts" do
|
||||
it "returns all the posts the user can see" do
|
||||
self_post = alice.post(:status_message, :text => "hi", :to => @alices_aspect.id)
|
||||
visible_post = bob.post(:status_message, :text => "hello", :to => @bobs_aspect.id)
|
||||
it "contains your public posts" do
|
||||
public_post = alice.post(:status_message, :text => "hi", :to => @alices_aspect.id, :public => true)
|
||||
alice.visible_posts.should include(public_post)
|
||||
end
|
||||
it "contains your non-public posts" do
|
||||
private_post = alice.post(:status_message, :text => "hi", :to => @alices_aspect.id, :public => false)
|
||||
alice.visible_posts.should include(private_post)
|
||||
end
|
||||
it "contains public posts from people you're following" do
|
||||
dogs = bob.aspects.create(:name => "dogs")
|
||||
bobs_public_post = bob.post(:status_message, :text => "hello", :public => true, :to => dogs.id)
|
||||
alice.visible_posts.should include(bobs_public_post)
|
||||
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_posts.should include(bobs_post)
|
||||
end
|
||||
it "does not contain non-public posts from aspects you're not in" do
|
||||
dogs = bob.aspects.create(:name => "dogs")
|
||||
invisible_post = bob.post(:status_message, :text => "foobar", :to => dogs.id)
|
||||
alice.visible_posts.should_not include(invisible_post)
|
||||
end
|
||||
it "does not contain duplicate posts" do
|
||||
bobs_other_aspect = bob.aspects.create(:name => "cat people")
|
||||
bob.add_contact_to_aspect(bob.contact_for(alice.person), bobs_other_aspect)
|
||||
bob.aspects_with_person(alice.person).should =~ [@bobs_aspect, bobs_other_aspect]
|
||||
|
||||
stream = alice.visible_posts
|
||||
stream.should include(self_post)
|
||||
stream.should include(visible_post)
|
||||
stream.should_not include(invisible_post)
|
||||
bobs_post = bob.post(:status_message, :text => "hai to all my people", :to => [@bobs_aspect.id, bobs_other_aspect.id])
|
||||
|
||||
alice.visible_posts.length.should == 1
|
||||
alice.visible_posts.should include(bobs_post)
|
||||
end
|
||||
context 'with many posts' do
|
||||
before do
|
||||
|
|
@ -63,7 +84,6 @@ describe User do
|
|||
bob.visible_posts(opts).map { |p| p.id }.should == bob.visible_posts(:limit => 40)[15...30].map { |p| p.id } #pagination should return the right posts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with two posts' do
|
||||
before do
|
||||
|
|
@ -78,7 +98,6 @@ describe User do
|
|||
@pending_status_message = eve.post :status_message, :text => "hey", :public => true, :to => @eves_aspect.id, :pending => true
|
||||
end
|
||||
|
||||
describe "#visible_posts" do
|
||||
it "queries by person id" do
|
||||
query = eve.visible_posts.where(:author_id => eve.person.id)
|
||||
query.include?(@status_message1).should == true
|
||||
|
|
@ -116,11 +135,6 @@ describe User do
|
|||
eve.visible_posts.should_not include @pending_status_message
|
||||
end
|
||||
|
||||
it '#find_visible_post_by_id' do
|
||||
eve.find_visible_post_by_id(@status_message1.id).should == @status_message1
|
||||
eve.find_visible_post_by_id(@status_message5.id).should == nil
|
||||
end
|
||||
|
||||
it 'is not emptied by a load of pending photos' do
|
||||
15.times {
|
||||
eve.build_post(:photo, :pending => true, :user_file=> File.open(photo_fixture_name), :to => eve.aspect_ids, :updated_at => Time.now + 1.day).save!
|
||||
|
|
@ -135,6 +149,10 @@ describe User do
|
|||
query = eve.visible_posts(:type => 'StatusMessage')
|
||||
query.map { |p| p.id }.should =~ [@status_message1, @status_message2, @status_message3, @status_message4].map { |p| p.id }
|
||||
end
|
||||
it '#find_visible_post_by_id' do
|
||||
eve.find_visible_post_by_id(@status_message1.id).should == @status_message1
|
||||
eve.find_visible_post_by_id(@status_message5.id).should == nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue