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

Merge branch 'master' of github.com:diaspora/diaspora

parents b01928af c4a86e03
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -35,11 +35,6 @@ module Diaspora ...@@ -35,11 +35,6 @@ module Diaspora
aspects.detect{|x| x.id == id } aspects.detect{|x| x.id == id }
end end
def album_by_id( id )
id = id.to_id
albums.detect{|x| x.id == id }
end
def aspects_with_post( id ) def aspects_with_post( id )
self.aspects.find_all_by_post_ids( id.to_id ) self.aspects.find_all_by_post_ids( id.to_id )
end end
......
...@@ -7,83 +7,80 @@ ...@@ -7,83 +7,80 @@
require File.dirname(__FILE__) + '/../../spec_helper' require File.dirname(__FILE__) + '/../../spec_helper'
describe User do describe User do
before do let(:user) { Factory(:user) }
@user = Factory.create(:user)
@aspect = @user.aspect(:name => 'heroes') let(:user2) { Factory(:user) }
@aspect2 = @user.aspect(:name => 'losers') let(:user3) { Factory(:user) }
let(:user4) { Factory(:user) }
@user2 = Factory.create :user
@user2_aspect = @user2.aspect(:name => 'dudes') let!(:aspect) { user.aspect(:name => 'heroes') }
let!(:aspect2) { user.aspect(:name => 'losers') }
friend_users(@user, @aspect, @user2, @user2_aspect)
let!(:user2_aspect) { user2.aspect(:name => 'dudes') }
@user3 = Factory.create :user let!(:user3_aspect) { user3.aspect(:name => 'dudes') }
@user3_aspect = @user3.aspect(:name => 'dudes') let!(:user4_aspect) { user4.aspect(:name => 'dudes') }
friend_users(@user, @aspect2, @user3, @user3_aspect)
let(:status_message1) { user2.post :status_message, :message => "hi", :to => user2_aspect.id }
@user4 = Factory.create :user let(:status_message2) { user3.post :status_message, :message => "heyyyy", :to => user3_aspect.id }
@user4_aspect = @user4.aspect(:name => 'dudes') let(:status_message3) { user4.post :status_message, :message => "yooo", :to => user4_aspect.id }
friend_users(@user, @aspect2, @user4, @user4_aspect)
end before do
friend_users(user, aspect, user2, user2_aspect)
it 'should generate a valid stream for a aspect of people' do friend_users(user, aspect2, user3, user3_aspect)
status_message1 = @user2.post :status_message, :message => "hi", :to => @user2_aspect.id friend_users(user, aspect2, user4, user4_aspect)
status_message2 = @user3.post :status_message, :message => "heyyyy", :to => @user3_aspect.id end
status_message3 = @user4.post :status_message, :message => "yooo", :to => @user4_aspect.id
it 'should generate a valid stream for a aspect of people' do
@user.receive status_message1.to_diaspora_xml (1..3).each{ |n|
@user.receive status_message2.to_diaspora_xml eval("user.receive status_message#{n}.to_diaspora_xml")
@user.receive status_message3.to_diaspora_xml }
@user.reload
user.visible_posts(:by_members_of => aspect).should include status_message1
@user.visible_posts(:by_members_of => @aspect).include?(status_message1).should be true user.visible_posts(:by_members_of => aspect).should_not include status_message2
@user.visible_posts(:by_members_of => @aspect).include?(status_message2).should be false user.visible_posts(:by_members_of => aspect).should_not include status_message3
@user.visible_posts(:by_members_of => @aspect).include?(status_message3).should be false
user.visible_posts(:by_members_of => aspect2).should_not include status_message1
@user.visible_posts(:by_members_of => @aspect2).include?(status_message1).should be false user.visible_posts(:by_members_of => aspect2).should include status_message2
@user.visible_posts(:by_members_of => @aspect2).include?(status_message2).should be true user.visible_posts(:by_members_of => aspect2).should include status_message3
@user.visible_posts(:by_members_of => @aspect2).include?(status_message3).should be true end
context 'querying' do
describe '#find_visible_post_by_id' do
it 'should query' do
user2.find_visible_post_by_id(status_message1.id).should == status_message1
user.find_visible_post_by_id(status_message1.id).should == nil
end
end end
end
describe 'querying' do context 'albums' do
it 'should find a visible post by id' do
status_message1 = @user.post :status_message, :message => "hi", :to => @aspect.id
status_message2 = @user2.post :status_message, :message => "heyyyy", :to => @user2_aspect.id
status_message3 = @user3.post :status_message, :message => "yooo", :to => @user3_aspect.id
@user.find_visible_post_by_id(status_message1.id).should == status_message1 before do
@user2.find_visible_post_by_id(status_message1.id).should == nil @album = user.post :album, :name => "Georges", :to => aspect.id
end aspect.reload
aspect2.reload
user.reload
end @album2 = user.post :album, :name => "Borges", :to => aspect.id
aspect.reload
aspect2.reload
user.reload
describe 'albums' do user.post :album, :name => "Luises", :to => aspect2.id
before do aspect.reload
@album = @user.post :album, :name => "Georges", :to => @aspect.id aspect2.reload
@aspect.reload user.reload
@aspect2.reload end
@user.reload
@album2 = @user.post :album, :name => "Borges", :to => @aspect.id
@aspect.reload
@aspect2.reload
@user.reload
@user.post :album, :name => "Luises", :to => @aspect2.id
@aspect.reload
@aspect2.reload
@user.reload
end
it 'should find all albums if passed :all' do it 'should find all albums if passed :all' do
@user.albums_by_aspect(:all).size.should == 3 user.albums_by_aspect(:all).should have(3).albums
end end
it 'should return the right number of albums' do it 'should return the right number of albums' do
@user.albums_by_aspect(@aspect).size.should == 2 user.albums_by_aspect(aspect).should have(2).albums
@user.albums_by_aspect(@aspect2).size.should == 1 user.albums_by_aspect(aspect2).should have(1).album
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