Sha256: f819af44aaa75c01f1f4b761a4f38475c4cd035f1b07237c0c281026a446ea08

Contents?: true

Size: 1.97 KB

Versions: 5

Compression:

Stored size: 1.97 KB

Contents

require 'test_helper'

class AdminControllerTest < ActionController::TestCase
  fixtures :users, :categories, :roles
  
  def test_should_get_index
    login_as :admin
    get :users
    assert_response :success
  end

  def test_should_not_get_index
    login_as :quentin
    get :users
    assert_redirected_to login_path
  end
  
  def test_should_not_activate_user
    login_as :quentin
    users(:quentin).update_attribute('activation_code', 'test')
    users(:quentin).update_attribute('activated_at', nil)    
        
    put :activate_user, :id => 1
    assert !users(:quentin).active?
    assert_redirected_to login_path
  end
  
  def test_should_not_activate_user_js
    users(:quentin).update_attribute('activation_code', 'test')
    users(:quentin).update_attribute('activated_at', nil)    
    
    get :activate_user, :id => 1, :format => 'js'
    assert !users(:quentin).active?
  end
  

  def test_should_activate_user
    users(:quentin).update_attribute('activation_code', 'test')
    users(:quentin).update_attribute('activated_at', nil)    

    login_as :admin
    put :activate_user, :id => users(:quentin).id
    assert_response :redirect    
    assert users(:quentin).reload.active?
  end
  
  def test_should_deactivate_user
    login_as :admin
    put :deactivate_user, :id => users(:quentin).id
    assert_response :redirect    
    assert !users(:quentin).reload.active?    
  end
  
  test "should list users" do
    login_as :admin
    get :users
    assert_response :success
    assert !assigns(:users).empty?
  end
  
  test "should search users" do
    login_as :admin
    get :users, :login => 'admin'
    assert_response :success
    assert !assigns(:users).empty?
  end
  
  test "should clear cache" do
    login_as :admin
    get :clear_cache
    assert_redirected_to admin_dashboard_path
  end
  
  test "should get subscribers xml" do
    authorize_as :admin

    get :subscribers, :format => :xml
    assert_response :success
    assert assigns(:users).any?
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
community_engine-2.3.2 test/functional/admin_controller_test.rb
community_engine-2.3.1 test/functional/admin_controller_test.rb
community_engine-2.3.0 test/functional/admin_controller_test.rb
community_engine-2.1.0 test/functional/admin_controller_test.rb
community_engine-2.0.0 test/functional/admin_controller_test.rb