diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index e72409d52..c882453c6 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -5,10 +5,10 @@ require 'spec_helper' describe User do - before do - @user = Factory.create(:user) - @aspect = @user.aspect(:name => 'heroes') - end + before do + @user = Factory.create(:user) + @aspect = @user.aspect(:name => 'heroes') + end describe 'friend requesting' do it "should assign a request to a aspect" do @@ -22,7 +22,7 @@ describe User do aspect.requests.size.should == 1 end - it "should be able to accept a pending friend request" do + it "should be able to accept a pending friend request" do friend = Factory.create(:person) r = Request.instantiate(:to => @user.receive_url, :from => friend) r.save @@ -45,12 +45,13 @@ describe User do Request.count.should == 0 end - it 'should not be able to friend request an existing friend' do friend = Factory.create(:person) + it 'should not be able to friend request an existing friend' do + friend = Factory.create(:person) @user.friends << friend @user.save - proc {@user.send_friend_request_to( friend, @aspect)}.should raise_error + proc { @user.send_friend_request_to(friend, @aspect) }.should raise_error end describe 'multiple users accepting/rejecting the same person' do @@ -133,7 +134,7 @@ describe User do @user2.receive @req_two_xml @user2.pending_requests.size.should be 1 - @user2.ignore_friend_request @user2.pending_requests.first.id#@request_two.id + @user2.ignore_friend_request @user2.pending_requests.first.id #@request_two.id @user2.friends.include?(@person_one).should be false Person.all.count.should be 3 end @@ -177,51 +178,46 @@ describe User do end - describe 'unfriending' do - before do - @user2 = Factory.create :user - @aspect2 = @user2.aspect(:name => "Gross people") - - friend_users(@user, @aspect, @user2, @aspect2) - @user.reload - @user2.reload - @aspect.reload - @aspect2.reload - end - - it 'should unfriend the other user on the same seed' do - @user.friends.count.should == 1 - @user2.friends.count.should == 1 - - @user2.unfriend @user.person - @user2.friends.count.should be 0 - - @user.unfriended_by @user2.person - - @aspect.reload - @aspect2.reload - @aspect.people.count.should == 0 - @aspect2.people.count.should == 0 - end - context 'with a post' do + describe 'unfriending' do before do - @message = @user.post(:status_message, :message => "hi", :to => @aspect.id) - @user2.receive @message.to_diaspora_xml.to_s - @user2.unfriend @user.person - @user.unfriended_by @user2.person - @aspect.reload - @aspect2.reload + @user2 = Factory.create :user + @aspect2 = @user2.aspect(:name => "Gross people") + + friend_users(@user, @aspect, @user2, @aspect2) @user.reload @user2.reload + @aspect.reload + @aspect2.reload end - it "deletes the unfriended user's posts from visible_posts" do - @user.raw_visible_posts.include?(@message.id).should be_false + + it 'should unfriend the other user on the same seed' do + @user.friends.count.should == 1 + @user2.friends.count.should == 1 + + @user2.unfriend @user.person + @user2.friends.count.should be 0 + + @user.unfriended_by @user2.person + + @aspect.reload + @aspect2.reload + @aspect.people.count.should == 0 + @aspect2.people.count.should == 0 end - it "deletes the unfriended user's posts from the aspect's posts" do - @aspect2.posts.include?(@message).should be_false + context 'with a post' do + before do + @message = @user.post(:status_message, :message => "hi", :to => @aspect.id) + @user2.receive @message.to_diaspora_xml.to_s + @user2.unfriend @user.person + @user.unfriended_by @user2.person + end + it "deletes the unfriended user's posts from visible_posts" do + @user.raw_visible_posts(true).include?(@message.id).should be_false + end + it "deletes the unfriended user's posts from the aspect's posts" do + @aspect2.posts(true).include?(@message).should be_false + end end end end - - end end