Class: SessionsControllerTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- SessionsControllerTest
- Includes:
- AuthenticatedTestHelper
- Defined in:
- vendor/plugins/authentication/test/functional/sessions_controller_test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_should_delete_token_on_logout ⇒ Object
- #test_should_fail_cookie_login ⇒ Object
- #test_should_fail_expired_cookie_login ⇒ Object
- #test_should_fail_login_and_not_redirect ⇒ Object
- #test_should_login_and_redirect ⇒ Object
- #test_should_login_with_cookie ⇒ Object
- #test_should_logout ⇒ Object
- #test_should_not_remember_me ⇒ Object
- #test_should_remember_me ⇒ Object
Methods included from AuthenticatedTestHelper
Instance Method Details
#setup ⇒ Object
14 15 16 17 18 |
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 14 def setup @controller = SessionsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end |
#test_should_delete_token_on_logout ⇒ Object
49 50 51 52 53 |
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 49 def test_should_delete_token_on_logout login_as :quentin get :destroy assert_equal @response.["auth_token"], [] end |
#test_should_fail_cookie_login ⇒ Object
70 71 72 73 74 75 |
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 70 def users(:quentin).remember_me @request.["auth_token"] = auth_token('invalid_auth_token') get :new assert !@controller.send(:logged_in?) end |
#test_should_fail_expired_cookie_login ⇒ Object
62 63 64 65 66 67 68 |
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 62 def users(:quentin).remember_me users(:quentin).update_attribute :remember_token_expires_at, 5.minutes.ago @request.["auth_token"] = (:quentin) get :new assert !@controller.send(:logged_in?) end |
#test_should_fail_login_and_not_redirect ⇒ Object
26 27 28 29 30 |
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 26 def test_should_fail_login_and_not_redirect post :create, :login => 'quentin', :password => 'bad password' assert_nil session[:user_id] assert_response :success end |
#test_should_login_and_redirect ⇒ Object
20 21 22 23 24 |
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 20 def test_should_login_and_redirect post :create, :login => 'quentin', :password => 'test' assert session[:user_id] assert_response :redirect end |
#test_should_login_with_cookie ⇒ Object
55 56 57 58 59 60 |
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 55 def users(:quentin).remember_me @request.["auth_token"] = (:quentin) get :new assert @controller.send(:logged_in?) end |
#test_should_logout ⇒ Object
32 33 34 35 36 37 |
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 32 def test_should_logout login_as :quentin get :destroy assert_nil session[:user_id] assert_response :redirect end |
#test_should_not_remember_me ⇒ Object
44 45 46 47 |
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 44 def test_should_not_remember_me post :create, :login => 'quentin', :password => 'test', :remember_me => "0" assert_nil @response.["auth_token"] end |
#test_should_remember_me ⇒ Object
39 40 41 42 |
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 39 def test_should_remember_me post :create, :login => 'quentin', :password => 'test', :remember_me => "1" assert_not_nil @response.["auth_token"] end |