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