Mercurial > hg > soundsoftware-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
43 Token.delete_all | 43 Token.delete_all |
44 | 44 |
45 # User logs in with 'autologin' checked | 45 # User logs in with 'autologin' checked |
46 post '/login', :username => user.login, :password => 'admin', :autologin => 1 | 46 post '/login', :username => user.login, :password => 'admin', :autologin => 1 |
47 assert_redirected_to '/my/page' | 47 assert_redirected_to '/my/page' |
48 token = Token.find :first | 48 token = Token.first |
49 assert_not_nil token | 49 assert_not_nil token |
50 assert_equal user, token.user | 50 assert_equal user, token.user |
51 assert_equal 'autologin', token.action | 51 assert_equal 'autologin', token.action |
52 assert_equal user.id, session[:user_id] | 52 assert_equal user.id, session[:user_id] |
53 assert_equal token.value, cookies['autologin'] | 53 assert_equal token.value, cookies['autologin'] |
66 assert_template 'my/page' | 66 assert_template 'my/page' |
67 assert_equal user.id, session[:user_id] | 67 assert_equal user.id, session[:user_id] |
68 assert_not_nil user.reload.last_login_on | 68 assert_not_nil user.reload.last_login_on |
69 end | 69 end |
70 | 70 |
71 def test_autologin_should_use_autologin_cookie_name | |
72 Token.delete_all | |
73 Redmine::Configuration.stubs(:[]).with('autologin_cookie_name').returns('custom_autologin') | |
74 Redmine::Configuration.stubs(:[]).with('autologin_cookie_path').returns('/') | |
75 Redmine::Configuration.stubs(:[]).with('autologin_cookie_secure').returns(false) | |
76 | |
77 with_settings :autologin => '7' do | |
78 assert_difference 'Token.count' do | |
79 post '/login', :username => 'admin', :password => 'admin', :autologin => 1 | |
80 end | |
81 assert_response 302 | |
82 assert cookies['custom_autologin'].present? | |
83 token = cookies['custom_autologin'] | |
84 | |
85 # Session is cleared | |
86 reset! | |
87 cookies['custom_autologin'] = token | |
88 get '/my/page' | |
89 assert_response :success | |
90 | |
91 assert_difference 'Token.count', -1 do | |
92 post '/logout' | |
93 end | |
94 assert cookies['custom_autologin'].blank? | |
95 end | |
96 end | |
97 | |
71 def test_lost_password | 98 def test_lost_password |
72 Token.delete_all | 99 Token.delete_all |
73 | 100 |
74 get "account/lost_password" | 101 get "account/lost_password" |
75 assert_response :success | 102 assert_response :success |
77 assert_select 'input[name=mail]' | 104 assert_select 'input[name=mail]' |
78 | 105 |
79 post "account/lost_password", :mail => 'jSmith@somenet.foo' | 106 post "account/lost_password", :mail => 'jSmith@somenet.foo' |
80 assert_redirected_to "/login" | 107 assert_redirected_to "/login" |
81 | 108 |
82 token = Token.find(:first) | 109 token = Token.first |
83 assert_equal 'recovery', token.action | 110 assert_equal 'recovery', token.action |
84 assert_equal 'jsmith@somenet.foo', token.user.mail | 111 assert_equal 'jsmith@somenet.foo', token.user.mail |
85 assert !token.expired? | 112 assert !token.expired? |
86 | 113 |
87 get "account/lost_password", :token => token.value | 114 get "account/lost_password", :token => token.value |
135 post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar", | 162 post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar", |
136 :password => "newpass123", :password_confirmation => "newpass123"} | 163 :password => "newpass123", :password_confirmation => "newpass123"} |
137 assert_redirected_to '/login' | 164 assert_redirected_to '/login' |
138 assert !User.find_by_login('newuser').active? | 165 assert !User.find_by_login('newuser').active? |
139 | 166 |
140 token = Token.find(:first) | 167 token = Token.first |
141 assert_equal 'register', token.action | 168 assert_equal 'register', token.action |
142 assert_equal 'newuser@foo.bar', token.user.mail | 169 assert_equal 'newuser@foo.bar', token.user.mail |
143 assert !token.expired? | 170 assert !token.expired? |
144 | 171 |
145 get 'account/activate', :token => token.value | 172 get 'account/activate', :token => token.value |