Skip to content
Extraits de code Groupes Projets
Valider 8fddb4ec rédigé par ilya's avatar ilya
Parcourir les fichiers

MS IZ added test concerning people in multiple aspects

parent e6de6179
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -44,8 +44,7 @@ module Diaspora ...@@ -44,8 +44,7 @@ module Diaspora
end end
def aspects_with_person person def aspects_with_person person
id = person.id.to_id aspects.all(:person_ids => person.id)
aspects.select { |g| g.person_ids.include? id}
end end
def people_in_aspects aspects def people_in_aspects aspects
......
...@@ -8,11 +8,11 @@ describe AspectsController do ...@@ -8,11 +8,11 @@ describe AspectsController do
render_views render_views
before do before do
@user = Factory.create(:user) @user = Factory.create(:user)
@user.aspect(:name => "lame-os") @aspect = @user.aspect(:name => "lame-os")
@person = Factory.create(:person) @person = Factory.create(:person)
sign_in :user, @user sign_in :user, @user
end end
describe "#index" do describe "#index" do
it "assigns @friends to all the user's friends" do it "assigns @friends to all the user's friends" do
...@@ -46,4 +46,13 @@ describe AspectsController do ...@@ -46,4 +46,13 @@ describe AspectsController do
end end
end 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 end
...@@ -79,13 +79,26 @@ describe Aspect do ...@@ -79,13 +79,26 @@ describe Aspect do
aspect.people.size.should == 2 aspect.people.size.should == 2
end end
it 'should be accessible through the user' do describe '#aspects_with_person' do
aspects = user.aspects_with_person(friend) let!(:aspect_without_friend) {user.aspect(:name => "Another aspect")}
aspects.size.should == 1 it 'should return the aspects with given friend' do
aspects.first.id.should == aspect.id aspects = user.aspects_with_person(friend)
aspects.first.people.size.should == 2 aspects.size.should == 1
aspects.first.people.include?(friend).should be true aspects.first.id.should == aspect.id
aspects.first.people.include?(user2.person).should be true 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
end end
......
...@@ -72,6 +72,8 @@ describe User do ...@@ -72,6 +72,8 @@ describe User do
friend_users(user, aspect, user2, aspect2) friend_users(user, aspect, user2, aspect2)
friend_users(user, aspect, user3, aspect3) friend_users(user, aspect, user3, aspect3)
friend_users(user, aspect1, user4, aspect4) friend_users(user, aspect1, user4, aspect4)
user.add_person_to_aspect(user2.person.id, aspect1.id)
user.reload
end end
describe '#push_to_aspects' do describe '#push_to_aspects' do
...@@ -80,7 +82,7 @@ describe User do ...@@ -80,7 +82,7 @@ describe User do
user.push_to_aspects(post, aspect.id) user.push_to_aspects(post, aspect.id)
end 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.should_receive(:push_to_person).exactly(3).times
user.push_to_aspects(post, :all) user.push_to_aspects(post, :all)
end end
...@@ -92,5 +94,6 @@ describe User do ...@@ -92,5 +94,6 @@ describe User do
user.push_to_people(post, [user2.person, user3.person]) user.push_to_people(post, [user2.person, user3.person])
end end
end end
end end
end end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter