From 7b690f5dcbd0984a900de370aa5b2e52fdc515e0 Mon Sep 17 00:00:00 2001 From: ilya Date: Sat, 2 Oct 2010 13:20:23 -0700 Subject: [PATCH] slight publics controller spec refactor --- spec/controllers/publics_controller_spec.rb | 30 +++++++++------------ spec/models/user/receive_spec.rb | 1 - 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 83042ea55..d8d700bd8 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -7,6 +7,7 @@ require 'spec_helper' describe PublicsController do render_views let(:user) {Factory.create :user} + let(:user2){Factory.create :user} before do sign_in :user, user @@ -19,7 +20,6 @@ describe PublicsController do end it 'should accept a post from another node and save the information' do - user2 = Factory.create(:user) message = user2.build_post(:status_message, :message => "hi") user.reload @@ -42,33 +42,27 @@ describe PublicsController do end describe 'friend requests' do + let(:aspect2) {user2.aspect(:name => 'disciples')} + let!(:req) {user2.send_friend_request_to(user.person, aspect2)} + let!(:xml) {user2.salmon(req).xml_for(user.person)} before do - @user2 = Factory.create(:user) - aspect = @user2.aspect(:name => 'disciples') - - @user3 = Factory.create(:user) - - req = @user2.send_friend_request_to(user.person, aspect) - - @xml = @user2.salmon(req).xml_for(user.person) - req.delete - @user2.reload - @user2.pending_requests.count.should be 1 + user2.reload + user2.pending_requests.count.should be 1 end it 'should add the pending request to the right user if the target person exists locally' do - @user2.delete - post :receive, :id => user.person.id, :xml => @xml + user2.delete + post :receive, :id => user.person.id, :xml => xml assigns(:user).should eq(user) end it 'should add the pending request to the right user if the target person does not exist locally' do - Person.should_receive(:by_webfinger).with(@user2.person.diaspora_handle).and_return(@user2.person) - @user2.person.delete - @user2.delete - post :receive, :id => user.person.id, :xml => @xml + Person.should_receive(:by_webfinger).with(user2.person.diaspora_handle).and_return(user2.person) + user2.person.delete + user2.delete + post :receive, :id => user.person.id, :xml => xml assigns(:user).should eq(user) end diff --git a/spec/models/user/receive_spec.rb b/spec/models/user/receive_spec.rb index f11de234f..fce699cf6 100644 --- a/spec/models/user/receive_spec.rb +++ b/spec/models/user/receive_spec.rb @@ -177,7 +177,6 @@ describe User do end it 'should receive a salmon for a post' do - puts @salmon.inspect @user2.receive_salmon( @salmon.xml_for @user2.person ) @user2.visible_post_ids.include?(@post.id).should be true end