Skip to content
Snippets Groups Projects
Commit 8fddb4ec authored by ilya's avatar ilya
Browse files

MS IZ added test concerning people in multiple aspects

parent e6de6179
No related branches found
No related tags found
No related merge requests found
......@@ -44,8 +44,7 @@ module Diaspora
end
def aspects_with_person person
id = person.id.to_id
aspects.select { |g| g.person_ids.include? id}
aspects.all(:person_ids => person.id)
end
def people_in_aspects aspects
......
......@@ -8,11 +8,11 @@ describe AspectsController do
render_views
before do
@user = Factory.create(:user)
@user.aspect(:name => "lame-os")
@person = Factory.create(:person)
@user = Factory.create(:user)
@aspect = @user.aspect(:name => "lame-os")
@person = Factory.create(:person)
sign_in :user, @user
end
end
describe "#index" do
it "assigns @friends to all the user's friends" do
......@@ -46,4 +46,13 @@ describe AspectsController do
end
end
end
describe "#move_friend" do
let(:opts) { {:friend_id => "person_id", :from => "from_aspect_id", :to => {:to => "to_aspect_id"}}}
it 'calls the move_friend_method' do
pending "need to figure out how to stub current_user to return our test @user"
@user.should_receive(:move_friend).with( :friend_id => "person_id", :from => "from_aspect_id", :to => "to_aspect_id")
post :move_friend, opts
end
end
end
......@@ -79,13 +79,26 @@ describe Aspect do
aspect.people.size.should == 2
end
it 'should be accessible through the user' do
aspects = user.aspects_with_person(friend)
aspects.size.should == 1
aspects.first.id.should == aspect.id
aspects.first.people.size.should == 2
aspects.first.people.include?(friend).should be true
aspects.first.people.include?(user2.person).should be true
describe '#aspects_with_person' do
let!(:aspect_without_friend) {user.aspect(:name => "Another aspect")}
it 'should return the aspects with given friend' do
aspects = user.aspects_with_person(friend)
aspects.size.should == 1
aspects.first.id.should == aspect.id
aspects.first.people.size.should == 2
aspects.first.people.include?(friend).should be true
aspects.first.people.include?(user2.person).should be true
end
it 'returns multiple aspects if the person is there' do
user.reload
user.add_person_to_aspect(friend.id, aspect1.id)
aspects = user.aspects_with_person(friend)
aspects.count.should == 2
aspects.each{ |asp| asp.people.include?(friend) }
aspects.should_not include aspect_without_friend
end
end
end
......
......@@ -72,6 +72,8 @@ describe User do
friend_users(user, aspect, user2, aspect2)
friend_users(user, aspect, user3, aspect3)
friend_users(user, aspect1, user4, aspect4)
user.add_person_to_aspect(user2.person.id, aspect1.id)
user.reload
end
describe '#push_to_aspects' do
......@@ -80,7 +82,7 @@ describe User do
user.push_to_aspects(post, aspect.id)
end
it 'should push a post to all aspects' do
it 'should push a post to friends in all aspects' do
user.should_receive(:push_to_person).exactly(3).times
user.push_to_aspects(post, :all)
end
......@@ -92,5 +94,6 @@ describe User do
user.push_to_people(post, [user2.person, user3.person])
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment