GITSCM: Tweaked git scm view layout
[gitredmine.git] / test / integration / account_test.rb
blob6799b9288ca46f4366966f3ab4d215e23f34e96b
1 # redMine - project management software
2 # Copyright (C) 2006-2007  Jean-Philippe Lang
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 require "#{File.dirname(__FILE__)}/../test_helper"
20 class AccountTest < ActionController::IntegrationTest
21   fixtures :users
23   # Replace this with your real tests.
24   def test_login
25     get "my/page"
26     assert_redirected_to "account/login"
27     log_user('jsmith', 'jsmith')
28     
29     get "my/account"
30     assert_response :success
31     assert_template "my/account"    
32   end
33   
34   def test_lost_password
35     Token.delete_all
36     
37     get "account/lost_password"
38     assert_response :success
39     assert_template "account/lost_password"
40     
41     post "account/lost_password", :mail => 'jsmith@somenet.foo'
42     assert_redirected_to "account/login"
43     
44     token = Token.find(:first)
45     assert_equal 'recovery', token.action
46     assert_equal 'jsmith@somenet.foo', token.user.mail
47     assert !token.expired?
48     
49     get "account/lost_password", :token => token.value
50     assert_response :success
51     assert_template "account/password_recovery"
52     
53     post "account/lost_password", :token => token.value, :new_password => 'newpass', :new_password_confirmation => 'newpass'
54     assert_redirected_to "account/login"
55     assert_equal 'Password was successfully updated.', flash[:notice]
56     
57     log_user('jsmith', 'newpass')
58     assert_equal 0, Token.count    
59   end    
60 end