Show More
Commit Description:
force log out when password change
Commit Description:
force log out when password change
References:
File last commit:
Show/Diff file:
Action:
test/functional/user_admin_controller_test.rb | 142 lines | 3.1 KiB | text/x-ruby | RubyLexer |
pramook
initial commit...
r0 require File.dirname(__FILE__) + '/../test_helper'
require 'user_admin_controller'
# Re-raise errors caught by the controller.
class UserAdminController; def rescue_action(e) raise e end; end
Jittat Fakcharoenphol
started cleaning up tests, fixed fixtures loading error, removed error when contest time limit is uninitialized
r275 class UserAdminControllerTest < ActionController::TestCase
pramook
initial commit...
r0 fixtures :users
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 fixtures :roles
fixtures :rights
pramook
initial commit...
r0
def setup
@controller = UserAdminController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 @first_id = users(:john).id
@admin_id = users(:mary).id
end
def test_should_not_allow_new_user_to_see
get :list
assert_redirected_to :controller => 'main', :action => 'login'
pramook
initial commit...
r0 end
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 def test_should_not_allow_normal_user_to_see
john = users(:john)
get :list, {}, {:user_id => john.id}
assert_redirected_to :controller => 'main', :action => 'login'
end
def test_should_allow_admin_to_see
mary = users(:mary)
get :list, {}, {:user_id => mary.id}
assert_template 'user_admin/list'
end
pramook
initial commit...
r0 def test_index
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 get :index, {}, {:user_id => @admin_id}
pramook
initial commit...
r0 assert_response :success
assert_template 'list'
end
def test_list
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 get :list, {}, {:user_id => @admin_id}
pramook
initial commit...
r0
assert_response :success
assert_template 'list'
assert_not_nil assigns(:users)
end
def test_show
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 get :show, {:id => @first_id}, {:user_id => @admin_id}
pramook
initial commit...
r0
assert_response :success
assert_template 'show'
assert_not_nil assigns(:user)
end
def test_new
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 get :new, {}, {:user_id => @admin_id}
pramook
initial commit...
r0
assert_response :success
assert_template 'new'
assert_not_nil assigns(:user)
end
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 def test_create_with_correct_confirmation_password
pramook
initial commit...
r0 num_users = User.count
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 post :create, {:user => {
:login => 'test',
:full_name => 'hello',
:password => 'abcde',
:password_confirmation => 'abcde'
}}, {:user_id => @admin_id}
pramook
initial commit...
r0
assert_response :redirect
assert_redirected_to :action => 'list'
assert_equal num_users + 1, User.count
end
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 def test_create_with_wrong_confirmation_password
num_users = User.count
post :create, {:user => {
:login => 'test',
:full_name => 'hello',
:password => 'abcde',
:password_confirmation => 'abcdef'
}}, {:user_id => @admin_id}
assert_response :success
assert_template 'new'
assert_equal num_users, User.count
end
pramook
initial commit...
r0 def test_edit
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 get :edit, {:id => @first_id}, {:user_id => @admin_id}
pramook
initial commit...
r0
assert_response :success
assert_template 'edit'
assert_not_nil assigns(:user)
end
def test_update
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 post :update, {
:id => @first_id,
:user => {
:login => 'test',
:full_name => 'hello',
:password => 'abcde',
:password_confirmation => 'abcde'
}
}, {:user_id => @admin_id}
pramook
initial commit...
r0 assert_response :redirect
assert_redirected_to :action => 'show', :id => @first_id
end
def test_destroy
assert_nothing_raised {
User.find(@first_id)
}
jittat
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
r58 post :destroy, {:id => @first_id}, {:user_id => @admin_id}
pramook
initial commit...
r0 assert_response :redirect
assert_redirected_to :action => 'list'
assert_raise(ActiveRecord::RecordNotFound) {
User.find(@first_id)
}
end
end