Add people#show specs around showing the right set of posts.
This commit is contained in:
parent
77adc02cbd
commit
b0d98b9ce8
2 changed files with 25 additions and 5 deletions
|
|
@ -138,21 +138,40 @@ describe PeopleController do
|
||||||
get :show, :id => @person.id
|
get :show, :id => @person.id
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "assigns only the posts the current user can see" do
|
||||||
|
bob.posts.should be_empty
|
||||||
|
posts_user_can_see = []
|
||||||
|
posts_user_can_see << bob.post(:status_message, :message => "to an aspect @user is in", :to => bob.aspects[0].id)
|
||||||
|
bob.post(:status_message, :message => "to an aspect @user is not in", :to => bob.aspects[1].id)
|
||||||
|
posts_user_can_see << bob.post(:status_message, :message => "to all aspects", :to => 'all')
|
||||||
|
posts_user_can_see << bob.post(:status_message, :message => "public", :to => 'all', :public => true)
|
||||||
|
bob.reload.posts.length.should == 4
|
||||||
|
|
||||||
|
get :show, :id => @person.id
|
||||||
|
assigns(:posts).should =~ posts_user_can_see
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the person is not a contact of the current user" do
|
context "when the person is not a contact of the current user" do
|
||||||
before do
|
before do
|
||||||
@person = eve.person
|
@person = eve.person
|
||||||
end
|
end
|
||||||
|
|
||||||
it "succeeds" do
|
it "succeeds" do
|
||||||
get :show, :id => @person.id
|
get :show, :id => @person.id
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
it "shows public posts only" do
|
|
||||||
status_message = @person.owner.post(:status_message, :message => "hey there", :to => 'all', :public => true)
|
it "assigns only public posts" do
|
||||||
|
eve.posts.should be_empty
|
||||||
|
eve.post(:status_message, :message => "to an aspect @user is not in", :to => eve.aspects.first.id)
|
||||||
|
eve.post(:status_message, :message => "to all aspects", :to => 'all')
|
||||||
|
public_post = eve.post(:status_message, :message => "public", :to => 'all', :public => true)
|
||||||
|
eve.reload.posts.length.should == 3
|
||||||
|
|
||||||
get :show, :id => @person.id
|
get :show, :id => @person.id
|
||||||
assigns[:posts].should include status_message
|
assigns[:posts].should =~ [public_post]
|
||||||
response.body.should include status_message.message
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@ FixtureBuilder.configure do |fbuilder|
|
||||||
# now declare objects
|
# now declare objects
|
||||||
fbuilder.factory do
|
fbuilder.factory do
|
||||||
alice = Factory(:user_with_aspect, :username => "alice")
|
alice = Factory(:user_with_aspect, :username => "alice")
|
||||||
bob = Factory(:user_with_aspect, :username => "bob")
|
|
||||||
eve = Factory(:user_with_aspect, :username => "eve")
|
eve = Factory(:user_with_aspect, :username => "eve")
|
||||||
|
bob = Factory(:user_with_aspect, :username => "bob")
|
||||||
|
Factory(:aspect, :name => "empty", :user => bob)
|
||||||
|
|
||||||
connect_users(bob, bob.aspects.first, alice, alice.aspects.first)
|
connect_users(bob, bob.aspects.first, alice, alice.aspects.first)
|
||||||
connect_users(bob, bob.aspects.first, eve, eve.aspects.first)
|
connect_users(bob, bob.aspects.first, eve, eve.aspects.first)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue