@@ -1,16 +1,16 | |||
|
1 |
# |
|
|
2 |
# Copyright (C) 2006-20 |
|
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2011 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. |
@@ -23,7 +23,7 class MyController; def rescue_action(e) raise e end; end | |||
|
23 | 23 | |
|
24 | 24 | class MyControllerTest < ActionController::TestCase |
|
25 | 25 | fixtures :users, :user_preferences, :roles, :projects, :issues, :issue_statuses, :trackers, :enumerations, :custom_fields |
|
26 | ||
|
26 | ||
|
27 | 27 | def setup |
|
28 | 28 | @controller = MyController.new |
|
29 | 29 | @request = ActionController::TestRequest.new |
@@ -36,30 +36,30 class MyControllerTest < ActionController::TestCase | |||
|
36 | 36 | assert_response :success |
|
37 | 37 | assert_template 'page' |
|
38 | 38 | end |
|
39 | ||
|
39 | ||
|
40 | 40 | def test_page |
|
41 | 41 | get :page |
|
42 | 42 | assert_response :success |
|
43 | 43 | assert_template 'page' |
|
44 | 44 | end |
|
45 | ||
|
45 | ||
|
46 | 46 | def test_my_account_should_show_editable_custom_fields |
|
47 | 47 | get :account |
|
48 | 48 | assert_response :success |
|
49 | 49 | assert_template 'account' |
|
50 | 50 | assert_equal User.find(2), assigns(:user) |
|
51 | ||
|
51 | ||
|
52 | 52 | assert_tag :input, :attributes => { :name => 'user[custom_field_values][4]'} |
|
53 | 53 | end |
|
54 | ||
|
54 | ||
|
55 | 55 | def test_my_account_should_not_show_non_editable_custom_fields |
|
56 | 56 | UserCustomField.find(4).update_attribute :editable, false |
|
57 | ||
|
57 | ||
|
58 | 58 | get :account |
|
59 | 59 | assert_response :success |
|
60 | 60 | assert_template 'account' |
|
61 | 61 | assert_equal User.find(2), assigns(:user) |
|
62 | ||
|
62 | ||
|
63 | 63 | assert_no_tag :input, :attributes => { :name => 'user[custom_field_values][4]'} |
|
64 | 64 | end |
|
65 | 65 | |
@@ -72,7 +72,7 class MyControllerTest < ActionController::TestCase | |||
|
72 | 72 | :group_ids => ['10'], |
|
73 | 73 | :custom_field_values => {"4" => "0100562500"} |
|
74 | 74 | } |
|
75 | ||
|
75 | ||
|
76 | 76 | assert_redirected_to '/my/account' |
|
77 | 77 | user = User.find(2) |
|
78 | 78 | assert_equal user, assigns(:user) |
@@ -83,28 +83,28 class MyControllerTest < ActionController::TestCase | |||
|
83 | 83 | assert !user.admin? |
|
84 | 84 | assert user.groups.empty? |
|
85 | 85 | end |
|
86 | ||
|
86 | ||
|
87 | 87 | def test_change_password |
|
88 | 88 | get :password |
|
89 | 89 | assert_response :success |
|
90 | 90 | assert_template 'password' |
|
91 | ||
|
91 | ||
|
92 | 92 | # non matching password confirmation |
|
93 |
post :password, :password => 'jsmith', |
|
|
93 | post :password, :password => 'jsmith', | |
|
94 | 94 | :new_password => 'hello', |
|
95 | 95 | :new_password_confirmation => 'hello2' |
|
96 | 96 | assert_response :success |
|
97 | 97 | assert_template 'password' |
|
98 | 98 | assert_tag :tag => "div", :attributes => { :class => "errorExplanation" } |
|
99 | ||
|
99 | ||
|
100 | 100 | # wrong password |
|
101 |
post :password, :password => 'wrongpassword', |
|
|
101 | post :password, :password => 'wrongpassword', | |
|
102 | 102 | :new_password => 'hello', |
|
103 | 103 | :new_password_confirmation => 'hello' |
|
104 | 104 | assert_response :success |
|
105 | 105 | assert_template 'password' |
|
106 | 106 | assert_equal 'Wrong password', flash[:error] |
|
107 | ||
|
107 | ||
|
108 | 108 | # good password |
|
109 | 109 | post :password, :password => 'jsmith', |
|
110 | 110 | :new_password => 'hello', |
@@ -112,13 +112,13 class MyControllerTest < ActionController::TestCase | |||
|
112 | 112 | assert_redirected_to '/my/account' |
|
113 | 113 | assert User.try_to_login('jsmith', 'hello') |
|
114 | 114 | end |
|
115 | ||
|
115 | ||
|
116 | 116 | def test_page_layout |
|
117 | 117 | get :page_layout |
|
118 | 118 | assert_response :success |
|
119 | 119 | assert_template 'page_layout' |
|
120 | 120 | end |
|
121 | ||
|
121 | ||
|
122 | 122 | def test_add_block |
|
123 | 123 | xhr :post, :add_block, :block => 'issuesreportedbyme' |
|
124 | 124 | assert_response :success |
@@ -155,7 +155,7 class MyControllerTest < ActionController::TestCase | |||
|
155 | 155 | should_set_the_flash_to /reset/ |
|
156 | 156 | should_redirect_to('my account') {'/my/account' } |
|
157 | 157 | end |
|
158 | ||
|
158 | ||
|
159 | 159 | context "with no rss_token" do |
|
160 | 160 | setup do |
|
161 | 161 | assert_nil User.find(2).rss_token |
@@ -189,7 +189,7 class MyControllerTest < ActionController::TestCase | |||
|
189 | 189 | should_set_the_flash_to /reset/ |
|
190 | 190 | should_redirect_to('my account') {'/my/account' } |
|
191 | 191 | end |
|
192 | ||
|
192 | ||
|
193 | 193 | context "with no api_token" do |
|
194 | 194 | setup do |
|
195 | 195 | assert_nil User.find(2).api_token |
General Comments 0
You need to be logged in to leave comments.
Login now