Sha256: 52de8a54a7fd412429e6b422c0378dd50090111f4abb2dc3ab111097f09f3d0a

Contents?: true

Size: 1.87 KB

Versions: 7

Compression:

Stored size: 1.87 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class Muck::ActivitiesControllerTest < ActionController::TestCase

  tests Muck::ActivitiesController

  context "activities controller" do
    setup do
      activate_authlogic
      @user = Factory(:user)
      login_as @user
    end

    context 'on GET to index (js)' do
      setup do
        @activity = Factory(:activity)
        get :index, :parent_type => @user.type, :parent_id => @user, :format => 'js', :latest_activity_id => @activity.to_param
      end
      should_respond_with :success
    end

    context 'on GET to index (js) no latest activity id' do
      setup do
        get :index, :parent_type => @user.type, :parent_id => @user, :format => 'js', :latest_activity_id => nil
      end
      should_respond_with :success
    end
    
    context 'on POST to create (js)' do
      setup do
        post :create, :activity => { :content => 'test activity' }, :parent_type => @user.type, :parent_id => @user, :format => 'js'
      end      
      should_respond_with :success
      should_not_set_the_flash
    end
        
    context 'on POST to create' do
      setup do
        post :create, :activity => { :content => 'test activity' }, :parent_type => @user.type, :parent_id => @user
      end      
      should_redirect_to('show user page (user dashboard)') { @user }
    end

    context 'on DELETE to destroy' do
      setup do
        @activity = Factory(:activity, :source => @user)
        delete :destroy, :id => @activity.id
      end
      should_respond_with :redirect
      should_set_the_flash_to(I18n.t("muck.activities.item_removed"))
    end
  
    context 'on DELETE to destroy (js)' do
      setup do
        @activity = Factory(:activity, :source => @user)
        delete :destroy, :id => @activity.id, :format => 'js'
      end
      should_respond_with :success
      should_not_set_the_flash
    end
    
  end
  
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
muck-activity-0.1.2 test/functional/activities_controller_test.rb
muck-activity-0.1.3 test/functional/activities_controller_test.rb
muck-activity-0.1.4 test/functional/activities_controller_test.rb
muck-activity-0.1.5 test/functional/activities_controller_test.rb
muck-activity-0.1.6 test/functional/activities_controller_test.rb
muck-activities-0.1.7 test/functional/activities_controller_test.rb
muck-activity-0.1.1 test/functional/activities_controller_test.rb