##// END OF EJS Templates
empty tokens table...
Jean-Philippe Lang -
r214:318c8717b8a0
parent child
Show More
@@ -1,100 +1,102
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require "#{File.dirname(__FILE__)}/../test_helper"
19 19
20 20 class AccountTest < ActionController::IntegrationTest
21 21 fixtures :users
22 22
23 23 # Replace this with your real tests.
24 24 def test_login
25 25 get "my/page"
26 26 assert_redirected_to "account/login"
27 27 log_user('jsmith', 'jsmith')
28 28
29 29 get "my/account"
30 30 assert_response :success
31 31 assert_template "my/account"
32 32 end
33 33
34 34 def test_change_password
35 35 log_user('jsmith', 'jsmith')
36 36 get "my/account"
37 37 assert_response :success
38 38 assert_template "my/account"
39 39
40 40 post "my/change_password", :password => 'jsmith', :new_password => "hello", :new_password_confirmation => "hello2"
41 41 assert_response :success
42 42 assert_template "my/account"
43 43 assert_tag :tag => "div", :attributes => { :class => "errorExplanation" }
44 44
45 45 post "my/change_password", :password => 'jsmithZZ', :new_password => "hello", :new_password_confirmation => "hello"
46 46 assert_redirected_to "my/account"
47 47 assert_equal 'Wrong password', flash[:notice]
48 48
49 49 post "my/change_password", :password => 'jsmith', :new_password => "hello", :new_password_confirmation => "hello"
50 50 assert_redirected_to "my/account"
51 51 log_user('jsmith', 'hello')
52 52 end
53 53
54 54 def test_my_account
55 55 log_user('jsmith', 'jsmith')
56 56 get "my/account"
57 57 assert_response :success
58 58 assert_template "my/account"
59 59
60 60 post "my/account", :user => {:firstname => "Joe", :login => "root", :admin => 1}
61 61 assert_response :success
62 62 assert_template "my/account"
63 63 user = User.find(2)
64 64 assert_equal "Joe", user.firstname
65 65 assert_equal "jsmith", user.login
66 66 assert_equal false, user.admin?
67 67 end
68 68
69 69 def test_my_page
70 70 log_user('jsmith', 'jsmith')
71 71 get "my/page"
72 72 assert_response :success
73 73 assert_template "my/page"
74 74 end
75 75
76 76 def test_lost_password
77 Token.delete_all
78
77 79 get "account/lost_password"
78 80 assert_response :success
79 81 assert_template "account/lost_password"
80 82
81 83 post "account/lost_password", :mail => 'jsmith@somenet.foo'
82 84 assert_redirected_to "account/login"
83 85
84 86 token = Token.find(:first)
85 87 assert_equal 'recovery', token.action
86 88 assert_equal 'jsmith@somenet.foo', token.user.mail
87 89 assert !token.expired?
88 90
89 91 get "account/lost_password", :token => token.value
90 92 assert_response :success
91 93 assert_template "account/password_recovery"
92 94
93 95 post "account/lost_password", :token => token.value, :new_password => 'newpass', :new_password_confirmation => 'newpass'
94 96 assert_redirected_to "account/login"
95 97 assert_equal 'Password was successfully updated.', flash[:notice]
96 98
97 99 log_user('jsmith', 'newpass')
98 100 assert_equal 0, Token.count
99 101 end
100 102 end
General Comments 0
You need to be logged in to leave comments. Login now