Skip to content
Extraits de code Groupes Projets
dashboards_controller_spec.rb 1,96 ko
Newer Older
  • Learn to ignore specific revisions
  • require File.dirname(__FILE__) + '/../spec_helper'
     
    
    describe DashboardsController do
    
    maxwell's avatar
    maxwell a validé
     render_views
    
        @user = Factory.create(:user, :profile => Profile.create( :first_name => "bob", :last_name => "smith"))
    
        request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
    
    
      it "on index sets a variable containing all a user's friends when a user is signed in" do
        sign_in :user, @user   
    
        assigns[:friends].should == Person.friends.all
    
      describe 'PubSubHubBuB intergration' do 
    
        describe 'incoming subscriptions' do
          it 'should register a friend' do
            Subscriber.all.count.should == 0 
           
            post :hub,  {:callback => "http://example.com/", 
                                :mode => 'subscribe', 
                                :topic => '/status_messages',
                                :verify => 'async'}
            response.status.should == 202
            
            Subscriber.all.count.should == 1
          end
    
          it 'should keep track of what topic a subscriber wants' do 
            post :hub,  {:callback => "http://example.com/", 
                                :mode => 'subscribe', 
                                :topic => '/status_messages',
                                :verify => 'async'}
            Subscriber.first.topic.should == '/status_messages' 
          end
        end
        
        it 'should return a 204 for a sync request' do
            post :hub,  {:callback => "http://example.com/", 
                                :mode => 'subscribe', 
                                :topic => '/status_messages',
                                :verify => 'sync'}
            response.status.should == 204
        end
        
        it 'should confirm subscription of a sync request' do
          post :hub,  {:callback => "http://example.com/", 
                       :mode => 'subscribe', 
                       :topic => '/status_messages',
                       :verify => 'sync'}
         
        end
    
      end