@@ -25,7 +25,9 class AccountController < ApplicationController | |||
|
25 | 25 | # Login request and validation |
|
26 | 26 | def login |
|
27 | 27 | if request.get? |
|
28 | logout_user | |
|
28 | if User.current.logged? | |
|
29 | redirect_to home_url | |
|
30 | end | |
|
29 | 31 | else |
|
30 | 32 | authenticate_user |
|
31 | 33 | end |
@@ -33,6 +33,14 class AccountControllerTest < ActionController::TestCase | |||
|
33 | 33 | assert_select 'input[name=password]' |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | def test_get_login_while_logged_in_should_redirect_to_home | |
|
37 | @request.session[:user_id] = 2 | |
|
38 | ||
|
39 | get :login | |
|
40 | assert_redirected_to '/' | |
|
41 | assert_equal 2, @request.session[:user_id] | |
|
42 | end | |
|
43 | ||
|
36 | 44 | def test_login_should_redirect_to_back_url_param |
|
37 | 45 | # request.uri is "test.host" in test environment |
|
38 | 46 | post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http://test.host/issues/show/1' |
General Comments 0
You need to be logged in to leave comments.
Login now