Skip to content
Extraits de code Groupes Projets
Valider 197bd8eb rédigé par Raphael's avatar Raphael
Parcourir les fichiers

make user/receive spec less repetitive

parent 74ec629b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -47,96 +47,52 @@ describe User do ...@@ -47,96 +47,52 @@ describe User do
end end
describe 'post refs' do describe 'post refs' do
it "should add a received post to the aspect and visible_posts array" do before do
status_message = user.post :status_message, :message => "hi", :to =>aspect.id @status_message = user2.post :status_message, :message => "hi", :to =>aspect2.id
user.receive @status_message.to_diaspora_xml, user2.person
user.reload user.reload
salmon = user.salmon(status_message).xml_for user2.person
user2.receive_salmon salmon
user2.reload
user2.raw_visible_posts.include?(status_message).should be true
aspect2.reload
aspect2.posts.include?(status_message).should be_true
end end
it 'should be removed on unfriending' do it "should add a received post to the aspect and visible_posts array" do
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id user.raw_visible_posts.include?(@status_message).should be true
user.receive status_message.to_diaspora_xml, user2.person aspect.reload
user.reload aspect.posts.include?(@status_message).should be_true
end
user.raw_visible_posts.count.should == 1
it 'should be removed on unfriending' do
user.unfriend(user2.person) user.unfriend(user2.person)
user.reload user.reload
user.raw_visible_posts.count.should == 0 user.raw_visible_posts.count.should == 0
Post.count.should be 1
end end
it 'should be remove a post if the noone links to it' do it 'should be remove a post if the noone links to it' do
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
user.receive status_message.to_diaspora_xml, user2.person
user.reload
user.raw_visible_posts.count.should == 1
person = user2.person person = user2.person
user2.delete user2.delete
user.unfriend(person)
lambda {user.unfriend(person)}.should change(Post, :count).by(-1)
user.reload user.reload
user.raw_visible_posts.count.should == 0 user.raw_visible_posts.count.should == 0
Post.count.should be 0
end end
it 'should keep track of user references for one person ' do it 'should keep track of user references for one person ' do
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id @status_message.reload
user.receive status_message.to_diaspora_xml, user2.person @status_message.user_refs.should == 1
user.reload
user.raw_visible_posts.count.should == 1
status_message.reload
status_message.user_refs.should == 1
user.unfriend(user2.person) user.unfriend(user2.person)
status_message.reload @status_message.reload
@status_message.user_refs.should == 0
user.reload
user.raw_visible_posts.count.should == 0
status_message.reload
status_message.user_refs.should == 0
Post.count.should be 1
end end
it 'should not override userrefs on receive by another person' do it 'should not override userrefs on receive by another person' do
user3.activate_friend(user2.person, aspect3) user3.activate_friend(user2.person, aspect3)
user3.receive @status_message.to_diaspora_xml, user2.person
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id @status_message.reload
user.receive status_message.to_diaspora_xml, user2.person @status_message.user_refs.should == 2
user3.receive status_message.to_diaspora_xml, user2.person
user.reload
user3.reload
user.raw_visible_posts.count.should == 1
status_message.reload
status_message.user_refs.should == 2
user.unfriend(user2.person) user.unfriend(user2.person)
status_message.reload @status_message.reload
@status_message.user_refs.should == 1
user.reload
user.raw_visible_posts.count.should == 0
status_message.reload
status_message.user_refs.should == 1
Post.count.should be 1
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