Mercurial > hg > soundsoftware-site
diff test/integration/account_test.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
line wrap: on
line diff
--- a/test/integration/account_test.rb Fri Jun 14 09:07:32 2013 +0100 +++ b/test/integration/account_test.rb Fri Jun 14 09:28:30 2013 +0100 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2012 Jean-Philippe Lang +# Copyright (C) 2006-2013 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -45,7 +45,7 @@ # User logs in with 'autologin' checked post '/login', :username => user.login, :password => 'admin', :autologin => 1 assert_redirected_to '/my/page' - token = Token.find :first + token = Token.first assert_not_nil token assert_equal user, token.user assert_equal 'autologin', token.action @@ -68,6 +68,33 @@ assert_not_nil user.reload.last_login_on end + def test_autologin_should_use_autologin_cookie_name + Token.delete_all + Redmine::Configuration.stubs(:[]).with('autologin_cookie_name').returns('custom_autologin') + Redmine::Configuration.stubs(:[]).with('autologin_cookie_path').returns('/') + Redmine::Configuration.stubs(:[]).with('autologin_cookie_secure').returns(false) + + with_settings :autologin => '7' do + assert_difference 'Token.count' do + post '/login', :username => 'admin', :password => 'admin', :autologin => 1 + end + assert_response 302 + assert cookies['custom_autologin'].present? + token = cookies['custom_autologin'] + + # Session is cleared + reset! + cookies['custom_autologin'] = token + get '/my/page' + assert_response :success + + assert_difference 'Token.count', -1 do + post '/logout' + end + assert cookies['custom_autologin'].blank? + end + end + def test_lost_password Token.delete_all @@ -79,7 +106,7 @@ post "account/lost_password", :mail => 'jSmith@somenet.foo' assert_redirected_to "/login" - token = Token.find(:first) + token = Token.first assert_equal 'recovery', token.action assert_equal 'jsmith@somenet.foo', token.user.mail assert !token.expired? @@ -137,7 +164,7 @@ assert_redirected_to '/login' assert !User.find_by_login('newuser').active? - token = Token.find(:first) + token = Token.first assert_equal 'register', token.action assert_equal 'newuser@foo.bar', token.user.mail assert !token.expired?