Skip to content
Extraits de code Groupes Projets
publics_controller_spec.rb 1,66 ko
Newer Older
  • Learn to ignore specific revisions
  • maxwell's avatar
    maxwell a validé
    require File.dirname(__FILE__) + '/../spec_helper'
     
    describe PublicsController do
     render_views
      
      before do
    
    maxwell's avatar
    maxwell a validé
        @user = Factory.create(:user)
    
      describe 'receive endpoint' do
    
    maxwell's avatar
    maxwell a validé
        it 'should have a and endpoint and return a 200 on successful receipt of a request' do
    
          post :receive, :id =>@user.person.id
    
    maxwell's avatar
    maxwell a validé
          response.code.should == '200'
        end
        
        it 'should accept a post from another node and save the information' do
    
          person = Factory.create(:person)
          message = StatusMessage.new(:message => 'foo', :person => person)
    
    maxwell's avatar
    maxwell a validé
          StatusMessage.all.count.should be 0
    
          post :receive, :id => @user.person.id, :xml => message.to_diaspora_xml
    
    maxwell's avatar
    maxwell a validé
          StatusMessage.all.count.should be 1
    
      describe 'friend requests' do
        before do
          @user2 = Factory.create(:user)
          @user2.person.save
    
          group = @user2.group(:name => 'disciples')
    
          @user3 = Factory.create(:user)
          @user3.person.save
    
    
          req = @user2.send_friend_request_to(@user.person.url, group.id)
    
    
          @xml = req.to_diaspora_xml
    
          @user2.reload
          @user2.pending_requests.count.should be 1
    
        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
          
    
          assigns(:user).should eq(@user)
    
        it 'should add the pending request to the right user if the target person does not exist locally' do 
    
          @user2.person.delete
          @user2.delete
          post :receive, :id => @user.person.id, :xml => @xml
    
    
          assigns(:user).should eq(@user)
    
    maxwell's avatar
    maxwell a validé
    end