Sha256: a5f915c2121b90bc2c3a9619909529e1b013a952707d3cf4263a68a0c1923fd2

Contents?: true

Size: 1.44 KB

Versions: 20

Compression:

Stored size: 1.44 KB

Contents

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

class Admin::UsersControllerTest < ActionController::TestCase
  # TODO: DRY tests. Check why login_as :admin doesn't work if inside #setup.
  
  def test_should_get_index
    login_as :admin
    
    get :index
    assert_response :success
    assert_not_nil assigns(:users)
  end

  def test_should_get_new
    login_as :admin

    get :new
    assert_response :success
  end
  
  def test_should_create_user
    login_as :admin

    assert_difference('User.count') do
      post :create, :user => params
    end

    assert_redirected_to :action => "show", :id => assigns(:user)
  end
  
  def test_should_show_user
    login_as :admin
    
    get :show, :id => users(:quentin).id
    assert_response :success
  end
  
  def test_should_get_edit
    login_as :admin
    
    get :edit, :id => users(:quentin).id
    assert_response :success
  end
  
  def test_should_update_user
    login_as :admin
    
    put :update, :id => users(:someone).id, :user => params
    assert_redirected_to :action => "show", :id => assigns(:user)
  end
  
  def test_should_destroy_user
    login_as :admin
    
    assert_difference('User.count', -1) do
      delete :destroy, :id => Fixtures.identify(:someone)
    end

    assert_redirected_to :action => "index"
  end
  
  private
    def params
      { :login => 'luca', :email => 'luca@talia.org',
        :password => 'luca', :password_confirmation => 'luca' }
    end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
talia_core-0.4.22 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.20 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.19 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.18 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.17 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.16 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.15 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.14 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.13 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.12 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.11 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.10 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.9 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.8 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.7 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.6 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.5 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.4 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.3 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb
talia_core-0.4.2 generators/talia_admin/templates/test/functional/admin/users_controller_test.rb