slight publics controller spec refactor

This commit is contained in:
ilya 2010-10-02 13:20:23 -07:00
parent f9cecd9d89
commit 7b690f5dcb
2 changed files with 12 additions and 19 deletions

View file

@ -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

View file

@ -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