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
|
end
|
||||||
|
|
||||||
describe "#visible_posts" do
|
describe "#visible_posts" do
|
||||||
it "returns all the posts the user can see" do
|
it "contains your public posts" do
|
||||||
self_post = alice.post(:status_message, :text => "hi", :to => @alices_aspect.id)
|
public_post = alice.post(:status_message, :text => "hi", :to => @alices_aspect.id, :public => true)
|
||||||
visible_post = bob.post(:status_message, :text => "hello", :to => @bobs_aspect.id)
|
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")
|
dogs = bob.aspects.create(:name => "dogs")
|
||||||
invisible_post = bob.post(:status_message, :text => "foobar", :to => dogs.id)
|
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
|
bobs_post = bob.post(:status_message, :text => "hai to all my people", :to => [@bobs_aspect.id, bobs_other_aspect.id])
|
||||||
stream.should include(self_post)
|
|
||||||
stream.should include(visible_post)
|
alice.visible_posts.length.should == 1
|
||||||
stream.should_not include(invisible_post)
|
alice.visible_posts.should include(bobs_post)
|
||||||
end
|
end
|
||||||
context 'with many posts' do
|
context 'with many posts' do
|
||||||
before 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
|
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
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context 'with two posts' do
|
context 'with two posts' do
|
||||||
before 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
|
@pending_status_message = eve.post :status_message, :text => "hey", :public => true, :to => @eves_aspect.id, :pending => true
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#visible_posts" do
|
|
||||||
it "queries by person id" do
|
it "queries by person id" do
|
||||||
query = eve.visible_posts.where(:author_id => eve.person.id)
|
query = eve.visible_posts.where(:author_id => eve.person.id)
|
||||||
query.include?(@status_message1).should == true
|
query.include?(@status_message1).should == true
|
||||||
|
|
@ -116,11 +135,6 @@ describe User do
|
||||||
eve.visible_posts.should_not include @pending_status_message
|
eve.visible_posts.should_not include @pending_status_message
|
||||||
end
|
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
|
it 'is not emptied by a load of pending photos' do
|
||||||
15.times {
|
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!
|
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 = eve.visible_posts(:type => 'StatusMessage')
|
||||||
query.map { |p| p.id }.should =~ [@status_message1, @status_message2, @status_message3, @status_message4].map { |p| p.id }
|
query.map { |p| p.id }.should =~ [@status_message1, @status_message2, @status_message3, @status_message4].map { |p| p.id }
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue