Show More
Commit Description:
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login...
Commit Description:
[web] added graders_right_to_admin_role, added a few functional tests: main, user_admin, graders, login git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@131 6386c4cd-e34a-4fa8-8920-d93eb39b512e
File last commit:
Show/Diff file:
Action:
test/functional/login_controller_test.rb | 37 lines | 1.0 KiB | text/x-ruby | RubyLexer |
require File.dirname(__FILE__) + '/../test_helper'
require 'login_controller'
# Re-raise errors caught by the controller.
class LoginController; def rescue_action(e) raise e end; end
class LoginControllerTest < Test::Unit::TestCase
fixtures :users
def setup
@controller = LoginController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
# Replace this with your real tests.
def test_should_hide_index
get :index
assert_redirected_to :controller => 'main', :action => 'login'
end
def test_should_login_user_and_set_session
john = users(:john)
post :login, :login => 'john', :password => "hello"
assert_redirected_to :controller => 'main', :action => 'list'
assert_equal john.id, session[:user_id]
end
def test_should_reject_user_with_wrong_password
john = users(:john)
post :login, :login => 'john', :password => "wrong"
assert_redirected_to :controller => 'main', :action => 'login'
end
end