Fixed: When logging in via an autologin cookie the user's last_login_on should be updated (#2820).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2524 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2009-02-25 14:59:33 +00:00
parent 94cc23f103
commit 21eb3c089d
5 changed files with 56 additions and 30 deletions
@@ -160,18 +160,6 @@ class AccountControllerTest < Test::Unit::TestCase
puts "Skipping openid tests."
end
def test_autologin
Setting.autologin = "7"
Token.delete_all
post :login, :username => 'admin', :password => 'admin', :autologin => 1
assert_redirected_to 'my/page'
token = Token.find :first
assert_not_nil token
assert_equal User.find_by_login('admin'), token.user
assert_equal 'autologin', token.action
end
def test_logout
@request.session[:user_id] = 2
get :logout
+32
View File
@@ -37,6 +37,38 @@ class AccountTest < ActionController::IntegrationTest
assert_template "my/account"
end
def test_autologin
user = User.find(1)
Setting.autologin = "7"
Token.delete_all
# User logs in with 'autologin' checked
post '/login', :username => user.login, :password => 'admin', :autologin => 1
assert_redirected_to 'my/page'
token = Token.find :first
assert_not_nil token
assert_equal user, token.user
assert_equal 'autologin', token.action
assert_equal user.id, session[:user_id]
assert_equal token.value, cookies['autologin']
# Session is cleared
reset!
User.current = nil
# Clears user's last login timestamp
user.update_attribute :last_login_on, nil
assert_nil user.reload.last_login_on
# User comes back with his autologin cookie
cookies[:autologin] = token.value
get '/my/page'
assert_response :success
assert_template 'my/page'
assert_equal user.id, session[:user_id]
assert_not_nil user.reload.last_login_on
assert user.last_login_on > 2.second.ago
end
def test_lost_password
Token.delete_all