Skip to content
Extraits de code Groupes Projets
sockets_controller_spec.rb 1,53 ko
Newer Older
  • Learn to ignore specific revisions
  • Raphael's avatar
    Raphael a validé
    #   Copyright (c) 2010, Diaspora Inc.  This file is
    
    Raphael's avatar
    Raphael a validé
    #   licensed under the Affero General Public License version 3 or later.  See
    
    Raphael's avatar
    Raphael a validé
    #   the COPYRIGHT file.
    
    require 'spec_helper'
    
    SocketsController.class_eval <<-EOT
    
    describe SocketsController do
    
      render_views
    
    maxwell's avatar
    maxwell a validé
      before do
    
        @user = make_user
    
        @controller = SocketsController.new
    
    maxwell's avatar
    maxwell a validé
      end
    
    
      it 'should unstub the websockets' do
    
          Diaspora::WebSocket.initialize_channels
    
          @controller.class.should == SocketsController
    
    maxwell's avatar
    maxwell a validé
      end
    
      describe 'actionhash' do
        before do
    
          @aspect = @user.aspects.create(:name => "losers")
    
    Raphael's avatar
    Raphael a validé
          @message = @user.post :status_message, :message => "post through user for victory", :to => @aspect.id
    
          @fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png'
        end
    
        it 'should actionhash photos' do
    
    danielvincent's avatar
    danielvincent a validé
          photo = @user.post(:photo, :album_id => nil, :to => @aspect.id, :user_file => File.open(@fixture_name))
          json  = @controller.action_hash(@user.id, photo, :aspect_ids => :all)
    
          json.include?('photo').should be_true
    
        end
    
        it 'should actionhash posts' do
    
          json = @controller.action_hash(@user.id, @message)
    
    maxwell's avatar
    maxwell a validé
          json.include?(@message.message).should be_true
          json.include?('status_message').should be_true
    
    maxwell's avatar
    maxwell a validé
    
    
        it 'should actionhash retractions' do
          retraction = Retraction.for @message
    
          json = @controller.action_hash(@user.id, retraction)
    
    maxwell's avatar
    maxwell a validé
          json.include?('retraction').should be_true
          json.include?("html\":null").should be_true
    
    maxwell's avatar
    maxwell a validé
    end