@@ -9,10 +9,10 wiki_content_versions_001: | |||
|
9 | 9 | wiki_content_id: 1 |
|
10 | 10 | compression: "" |
|
11 | 11 | data: |- |
|
12 | h1. CookBook documentation | |
|
13 | ||
|
12 | h1. CookBook documentation v1 | |
|
14 | 13 | |
|
15 | 14 | |
|
15 | Line from v1 | |
|
16 | 16 | Some [[documentation]] here... |
|
17 | 17 | wiki_content_versions_002: |
|
18 | 18 | updated_on: 2007-03-07 00:08:34 +01:00 |
@@ -24,10 +24,10 wiki_content_versions_002: | |||
|
24 | 24 | wiki_content_id: 1 |
|
25 | 25 | compression: "" |
|
26 | 26 | data: |- |
|
27 | h1. CookBook documentation | |
|
28 | ||
|
27 | h1. CookBook documentation v2 | |
|
29 | 28 | |
|
30 | 29 | |
|
30 | Line from v1 | |
|
31 | 31 | Some updated [[documentation]] here... |
|
32 | 32 | wiki_content_versions_003: |
|
33 | 33 | updated_on: 2007-03-07 00:10:51 +01:00 |
@@ -39,7 +39,8 wiki_content_versions_003: | |||
|
39 | 39 | wiki_content_id: 1 |
|
40 | 40 | compression: "" |
|
41 | 41 | data: |- |
|
42 | h1. CookBook documentation | |
|
42 | h1. CookBook documentation v3 | |
|
43 | ||
|
43 | 44 | Some updated [[documentation]] here... |
|
44 | 45 | wiki_content_versions_004: |
|
45 | 46 | data: |- |
@@ -161,14 +161,14 class BoardsControllerTest < Redmine::ControllerTest | |||
|
161 | 161 | post :create, :project_id => 1, :board => { :name => '', :description => 'Testing board creation'} |
|
162 | 162 | end |
|
163 | 163 | assert_response :success |
|
164 | assert_template 'new' | |
|
164 | assert_select_error /Name cannot be blank/ | |
|
165 | 165 | end |
|
166 | 166 | |
|
167 | 167 | def test_edit |
|
168 | 168 | @request.session[:user_id] = 2 |
|
169 | 169 | get :edit, :project_id => 1, :id => 2 |
|
170 | 170 | assert_response :success |
|
171 | assert_template 'edit' | |
|
171 | assert_select 'input[name=?][value=?]', 'board[name]', 'Discussion' | |
|
172 | 172 | end |
|
173 | 173 | |
|
174 | 174 | def test_edit_with_parent |
@@ -176,7 +176,6 class BoardsControllerTest < Redmine::ControllerTest | |||
|
176 | 176 | @request.session[:user_id] = 2 |
|
177 | 177 | get :edit, :project_id => 1, :id => board.id |
|
178 | 178 | assert_response :success |
|
179 | assert_template 'edit' | |
|
180 | 179 | |
|
181 | 180 | assert_select 'select[name=?]', 'board[parent_id]' do |
|
182 | 181 | assert_select 'option[value="2"][selected=selected]' |
@@ -204,7 +203,7 class BoardsControllerTest < Redmine::ControllerTest | |||
|
204 | 203 | @request.session[:user_id] = 2 |
|
205 | 204 | put :update, :project_id => 1, :id => 2, :board => { :name => '', :description => 'Testing board update'} |
|
206 | 205 | assert_response :success |
|
207 | assert_template 'edit' | |
|
206 | assert_select_error /Name cannot be blank/ | |
|
208 | 207 | end |
|
209 | 208 | |
|
210 | 209 | def test_destroy |
@@ -28,18 +28,17 class RolesControllerTest < Redmine::ControllerTest | |||
|
28 | 28 | def test_index |
|
29 | 29 | get :index |
|
30 | 30 | assert_response :success |
|
31 | assert_template 'index' | |
|
32 | ||
|
33 | assert_not_nil assigns(:roles) | |
|
34 | assert_equal Role.order('builtin, position').to_a, assigns(:roles) | |
|
35 | 31 | |
|
32 | assert_select 'table.roles tbody' do | |
|
33 | assert_select 'tr', Role.count | |
|
36 | 34 | assert_select 'a[href="/roles/1/edit"]', :text => 'Manager' |
|
37 | 35 | end |
|
36 | end | |
|
38 | 37 | |
|
39 | 38 | def test_new |
|
40 | 39 | get :new |
|
41 | 40 | assert_response :success |
|
42 | assert_template 'new' | |
|
41 | assert_select 'input[name=?]', 'role[name]' | |
|
43 | 42 | end |
|
44 | 43 | |
|
45 | 44 | def test_new_with_copy |
@@ -47,10 +46,7 class RolesControllerTest < Redmine::ControllerTest | |||
|
47 | 46 | |
|
48 | 47 | get :new, :params => {:copy => copy_from.id.to_s} |
|
49 | 48 | assert_response :success |
|
50 | assert_template 'new' | |
|
51 | ||
|
52 | role = assigns(:role) | |
|
53 | assert_equal copy_from.permissions, role.permissions | |
|
49 | assert_select 'input[name=?]', 'role[name]' | |
|
54 | 50 | |
|
55 | 51 | assert_select 'form' do |
|
56 | 52 | # blank name |
@@ -76,8 +72,7 class RolesControllerTest < Redmine::ControllerTest | |||
|
76 | 72 | } |
|
77 | 73 | } |
|
78 | 74 | assert_response :success |
|
79 | assert_template 'new' | |
|
80 | assert_select 'div#errorExplanation' | |
|
75 | assert_select_error /Name cannot be blank/ | |
|
81 | 76 | end |
|
82 | 77 | |
|
83 | 78 | def test_create_without_workflow_copy |
@@ -113,15 +108,16 class RolesControllerTest < Redmine::ControllerTest | |||
|
113 | 108 | def test_edit |
|
114 | 109 | get :edit, :params => {:id => 1} |
|
115 | 110 | assert_response :success |
|
116 | assert_template 'edit' | |
|
117 | assert_equal Role.find(1), assigns(:role) | |
|
111 | ||
|
112 | assert_select 'input[name=?][value=?]', 'role[name]', 'Manager' | |
|
118 | 113 | assert_select 'select[name=?]', 'role[issues_visibility]' |
|
119 | 114 | end |
|
120 | 115 | |
|
121 | 116 | def test_edit_anonymous |
|
122 | 117 | get :edit, :params => {:id => Role.anonymous.id} |
|
123 | 118 | assert_response :success |
|
124 | assert_template 'edit' | |
|
119 | ||
|
120 | assert_select 'input[name=?]', 'role[name]', 0 | |
|
125 | 121 | assert_select 'select[name=?]', 'role[issues_visibility]', 0 |
|
126 | 122 | end |
|
127 | 123 | |
@@ -165,7 +161,7 class RolesControllerTest < Redmine::ControllerTest | |||
|
165 | 161 | def test_update_with_failure |
|
166 | 162 | put :update, :params => {:id => 1, :role => {:name => ''}} |
|
167 | 163 | assert_response :success |
|
168 | assert_template 'edit' | |
|
164 | assert_select_error /Name cannot be blank/ | |
|
169 | 165 | end |
|
170 | 166 | |
|
171 | 167 | def test_destroy |
@@ -186,10 +182,6 class RolesControllerTest < Redmine::ControllerTest | |||
|
186 | 182 | def test_get_permissions |
|
187 | 183 | get :permissions |
|
188 | 184 | assert_response :success |
|
189 | assert_template 'permissions' | |
|
190 | ||
|
191 | assert_not_nil assigns(:roles) | |
|
192 | assert_equal Role.order('builtin, position').to_a, assigns(:roles) | |
|
193 | 185 | |
|
194 | 186 | assert_select 'input[name=?][type=checkbox][value=add_issues][checked=checked]', 'permissions[3][]' |
|
195 | 187 | assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]' |
@@ -30,15 +30,16 class SearchControllerTest < Redmine::ControllerTest | |||
|
30 | 30 | User.current = nil |
|
31 | 31 | end |
|
32 | 32 | |
|
33 | def test_search_for_projects | |
|
33 | def test_search_without_q_should_display_search_form | |
|
34 | 34 | get :index |
|
35 | 35 | assert_response :success |
|
36 | assert_template 'index' | |
|
36 | assert_select '#content input[name=q]' | |
|
37 | end | |
|
37 | 38 | |
|
39 | def test_search_for_projects | |
|
38 | 40 | get :index, :params => {:q => "cook"} |
|
39 | 41 | assert_response :success |
|
40 | assert_template 'index' | |
|
41 | assert assigns(:results).include?(Project.find(1)) | |
|
42 | assert_select '#search-results dt.project a', :text => /eCookbook/ | |
|
42 | 43 | end |
|
43 | 44 | |
|
44 | 45 | def test_search_on_archived_project_should_return_404 |
@@ -69,29 +70,32 class SearchControllerTest < Redmine::ControllerTest | |||
|
69 | 70 | get :index, :params => {:q => 'recipe subproject commit', :all_words => ''} |
|
70 | 71 | end |
|
71 | 72 | assert_response :success |
|
72 | assert_template 'index' | |
|
73 | 73 | |
|
74 | assert assigns(:results).include?(Issue.find(2)) | |
|
75 | assert assigns(:results).include?(Issue.find(5)) | |
|
76 | assert assigns(:results).include?(Changeset.find(101)) | |
|
74 | assert_select '#search-results' do | |
|
75 | assert_select 'dt.issue a', :text => /Feature request #2/ | |
|
76 | assert_select 'dt.issue a', :text => /Bug #5/ | |
|
77 | assert_select 'dt.changeset a', :text => /Revision 1/ | |
|
78 | ||
|
77 | 79 | assert_select 'dt.issue a', :text => /Add ingredients categories/ |
|
78 | 80 | assert_select 'dd', :text => /should be classified by categories/ |
|
81 | end | |
|
79 | 82 | |
|
80 | assert assigns(:result_count_by_type).is_a?(Hash) | |
|
81 | assert_equal 5, assigns(:result_count_by_type)['changesets'] | |
|
83 | assert_select '#search-results-counts' do | |
|
82 | 84 | assert_select 'a', :text => 'Changesets (5)' |
|
83 | 85 | end |
|
86 | end | |
|
84 | 87 | |
|
85 | 88 | def test_search_issues |
|
86 | 89 | get :index, :params => {:q => 'issue', :issues => 1} |
|
87 | 90 | assert_response :success |
|
88 | assert_template 'index' | |
|
89 | 91 | |
|
90 | assert_equal true, assigns(:all_words) | |
|
91 | assert_equal false, assigns(:titles_only) | |
|
92 | assert assigns(:results).include?(Issue.find(8)) | |
|
93 | assert assigns(:results).include?(Issue.find(5)) | |
|
94 |
assert_select 'dt.issue |
|
|
92 | assert_select 'input[name=all_words][checked=checked]' | |
|
93 | assert_select 'input[name=titles_only]:not([checked])' | |
|
94 | ||
|
95 | assert_select '#search-results' do | |
|
96 | assert_select 'dt.issue a', :text => /Bug #5/ | |
|
97 | assert_select 'dt.issue.closed a', :text => /Bug #8 \(Closed\)/ | |
|
98 | end | |
|
95 | 99 | end |
|
96 | 100 | |
|
97 | 101 | def test_search_issues_should_search_notes |
@@ -99,7 +103,10 class SearchControllerTest < Redmine::ControllerTest | |||
|
99 | 103 | |
|
100 | 104 | get :index, :params => {:q => 'searchkeyword', :issues => 1} |
|
101 | 105 | assert_response :success |
|
102 | assert_include Issue.find(2), assigns(:results) | |
|
106 | ||
|
107 | assert_select '#search-results' do | |
|
108 | assert_select 'dt.issue a', :text => /Feature request #2/ | |
|
109 | end | |
|
103 | 110 | end |
|
104 | 111 | |
|
105 | 112 | def test_search_issues_with_multiple_matches_in_journals_should_return_issue_once |
@@ -108,8 +115,11 class SearchControllerTest < Redmine::ControllerTest | |||
|
108 | 115 | |
|
109 | 116 | get :index, :params => {:q => 'searchkeyword', :issues => 1} |
|
110 | 117 | assert_response :success |
|
111 | assert_include Issue.find(2), assigns(:results) | |
|
112 | assert_equal 1, assigns(:results).size | |
|
118 | ||
|
119 | assert_select '#search-results' do | |
|
120 | assert_select 'dt.issue a', :text => /Feature request #2/ | |
|
121 | assert_select 'dt', 1 | |
|
122 | end | |
|
113 | 123 | end |
|
114 | 124 | |
|
115 | 125 | def test_search_issues_should_search_private_notes_with_permission_only |
@@ -119,66 +129,74 class SearchControllerTest < Redmine::ControllerTest | |||
|
119 | 129 | Role.find(1).add_permission! :view_private_notes |
|
120 | 130 | get :index, :params => {:q => 'searchkeyword', :issues => 1} |
|
121 | 131 | assert_response :success |
|
122 | assert_include Issue.find(2), assigns(:results) | |
|
132 | assert_select '#search-results' do | |
|
133 | assert_select 'dt.issue a', :text => /Feature request #2/ | |
|
134 | end | |
|
123 | 135 | |
|
124 | 136 | Role.find(1).remove_permission! :view_private_notes |
|
125 | 137 | get :index, :params => {:q => 'searchkeyword', :issues => 1} |
|
126 | 138 | assert_response :success |
|
127 | assert_not_include Issue.find(2), assigns(:results) | |
|
139 | assert_select '#search-results' do | |
|
140 | assert_select 'dt', :text => /Feature request #2/, :count => 0 | |
|
141 | end | |
|
128 | 142 | end |
|
129 | 143 | |
|
130 | 144 | def test_search_all_projects_with_scope_param |
|
131 | 145 | get :index, :params => {:q => 'issue', :scope => 'all'} |
|
132 | 146 | assert_response :success |
|
133 | assert_template 'index' | |
|
134 | assert assigns(:results).present? | |
|
147 | ||
|
148 | assert_select '#search-results dt' | |
|
135 | 149 | end |
|
136 | 150 | |
|
137 | 151 | def test_search_my_projects |
|
138 | 152 | @request.session[:user_id] = 2 |
|
139 | 153 | get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''} |
|
140 | 154 | assert_response :success |
|
141 | assert_template 'index' | |
|
142 | assert assigns(:results).include?(Issue.find(1)) | |
|
143 | assert !assigns(:results).include?(Issue.find(5)) | |
|
155 | ||
|
156 | assert_select '#search-results' do | |
|
157 | assert_select 'dt.issue', :text => /Bug #1/ | |
|
158 | assert_select 'dt', :text => /Bug #5/, :count => 0 | |
|
159 | end | |
|
144 | 160 | end |
|
145 | 161 | |
|
146 | 162 | def test_search_my_projects_without_memberships |
|
147 | 163 | # anonymous user has no memberships |
|
148 | 164 | get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''} |
|
149 | 165 | assert_response :success |
|
150 | assert_template 'index' | |
|
151 | assert assigns(:results).empty? | |
|
166 | ||
|
167 | assert_select '#search-results' do | |
|
168 | assert_select 'dt', 0 | |
|
169 | end | |
|
152 | 170 | end |
|
153 | 171 | |
|
154 | 172 | def test_search_project_and_subprojects |
|
155 | 173 | get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => ''} |
|
156 | 174 | assert_response :success |
|
157 | assert_template 'index' | |
|
158 | assert assigns(:results).include?(Issue.find(1)) | |
|
159 | assert assigns(:results).include?(Issue.find(5)) | |
|
175 | ||
|
176 | assert_select '#search-results' do | |
|
177 | assert_select 'dt.issue', :text => /Bug #1/ | |
|
178 | assert_select 'dt.issue', :text => /Bug #5/ | |
|
179 | end | |
|
160 | 180 | end |
|
161 | 181 | |
|
162 | 182 | def test_search_without_searchable_custom_fields |
|
163 |
CustomField.update_all |
|
|
183 | CustomField.update_all :searchable => false | |
|
164 | 184 | |
|
165 | 185 | get :index, :params => {:id => 1} |
|
166 | 186 | assert_response :success |
|
167 | assert_template 'index' | |
|
168 | assert_not_nil assigns(:project) | |
|
169 | 187 | |
|
170 | 188 | get :index, :params => {:id => 1, :q => "can"} |
|
171 | 189 | assert_response :success |
|
172 | assert_template 'index' | |
|
173 | 190 | end |
|
174 | 191 | |
|
175 | 192 | def test_search_with_searchable_custom_fields |
|
176 | 193 | get :index, :params => {:id => 1, :q => "stringforcustomfield"} |
|
177 | 194 | assert_response :success |
|
178 | results = assigns(:results) | |
|
179 |
assert_ |
|
|
180 | assert_equal 1, results.size | |
|
181 | assert results.include?(Issue.find(7)) | |
|
195 | ||
|
196 | assert_select '#search-results' do | |
|
197 | assert_select 'dt.issue', :text => /#7/ | |
|
198 | assert_select 'dt', 1 | |
|
199 | end | |
|
182 | 200 | end |
|
183 | 201 | |
|
184 | 202 | def test_search_without_attachments |
@@ -186,9 +204,12 class SearchControllerTest < Redmine::ControllerTest | |||
|
186 | 204 | attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' |
|
187 | 205 | |
|
188 | 206 | get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '0'} |
|
189 | results = assigns(:results) | |
|
190 | assert_equal 1, results.size | |
|
191 | assert_equal issue, results.first | |
|
207 | assert_response :success | |
|
208 | ||
|
209 | assert_select '#search-results' do | |
|
210 | assert_select 'dt.issue', :text => /##{issue.id}/ | |
|
211 | assert_select 'dt', 1 | |
|
212 | end | |
|
192 | 213 | end |
|
193 | 214 | |
|
194 | 215 | def test_search_attachments_only |
@@ -196,18 +217,26 class SearchControllerTest < Redmine::ControllerTest | |||
|
196 | 217 | attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' |
|
197 | 218 | |
|
198 | 219 | get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => 'only'} |
|
199 | results = assigns(:results) | |
|
200 | assert_equal 1, results.size | |
|
201 | assert_equal attachment.container, results.first | |
|
220 | assert_response :success | |
|
221 | ||
|
222 | assert_select '#search-results' do | |
|
223 | assert_select 'dt.issue', :text => / #1 / | |
|
224 | assert_select 'dt', 1 | |
|
225 | end | |
|
202 | 226 | end |
|
203 | 227 | |
|
204 | 228 | def test_search_with_attachments |
|
205 | Issue.generate! :subject => 'search_attachments' | |
|
229 | issue = Issue.generate! :subject => 'search_attachments' | |
|
206 | 230 | Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' |
|
207 | 231 | |
|
208 | 232 | get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '1'} |
|
209 | results = assigns(:results) | |
|
210 | assert_equal 2, results.size | |
|
233 | assert_response :success | |
|
234 | ||
|
235 | assert_select '#search-results' do | |
|
236 | assert_select 'dt.issue', :text => / #1 / | |
|
237 | assert_select 'dt.issue', :text => / ##{issue.id} / | |
|
238 | assert_select 'dt', 2 | |
|
239 | end | |
|
211 | 240 | end |
|
212 | 241 | |
|
213 | 242 | def test_search_open_issues |
@@ -215,78 +244,98 class SearchControllerTest < Redmine::ControllerTest | |||
|
215 | 244 | Issue.generate! :subject => 'search_open', :status_id => 5 |
|
216 | 245 | |
|
217 | 246 | get :index, :params => {:id => 1, :q => 'search_open', :open_issues => '1'} |
|
218 | results = assigns(:results) | |
|
219 | assert_equal 1, results.size | |
|
247 | assert_response :success | |
|
248 | ||
|
249 | assert_select '#search-results' do | |
|
250 | assert_select 'dt', 1 | |
|
251 | end | |
|
220 | 252 | end |
|
221 | 253 | |
|
222 | 254 | def test_search_all_words |
|
223 | 255 | # 'all words' is on by default |
|
224 | 256 | get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => '1'} |
|
225 | assert_equal true, assigns(:all_words) | |
|
226 | results = assigns(:results) | |
|
227 | assert_not_nil results | |
|
228 | assert_equal 1, results.size | |
|
229 | assert results.include?(Issue.find(3)) | |
|
257 | assert_response :success | |
|
258 | ||
|
259 | assert_select 'input[name=all_words][checked=checked]' | |
|
260 | assert_select '#search-results' do | |
|
261 | assert_select 'dt.issue', :text => / #3 / | |
|
262 | assert_select 'dt', 1 | |
|
263 | end | |
|
230 | 264 | end |
|
231 | 265 | |
|
232 | 266 | def test_search_one_of_the_words |
|
233 | 267 | get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => ''} |
|
234 | assert_equal false, assigns(:all_words) | |
|
235 | results = assigns(:results) | |
|
236 | assert_not_nil results | |
|
237 | assert_equal 3, results.size | |
|
238 | assert results.include?(Issue.find(3)) | |
|
268 | assert_response :success | |
|
269 | ||
|
270 | assert_select 'input[name=all_words]:not([checked])' | |
|
271 | assert_select '#search-results' do | |
|
272 | assert_select 'dt.issue', :text => / #3 / | |
|
273 | assert_select 'dt', 3 | |
|
274 | end | |
|
239 | 275 | end |
|
240 | 276 | |
|
241 | 277 | def test_search_titles_only_without_result |
|
242 | 278 | get :index, :params => {:id => 1, :q => 'recipe updating saving', :titles_only => '1'} |
|
243 | results = assigns(:results) | |
|
244 | assert_not_nil results | |
|
245 | assert_equal 0, results.size | |
|
279 | assert_response :success | |
|
280 | ||
|
281 | assert_select 'input[name=titles_only][checked=checked]' | |
|
282 | assert_select '#search-results' do | |
|
283 | assert_select 'dt', 0 | |
|
284 | end | |
|
246 | 285 | end |
|
247 | 286 | |
|
248 | 287 | def test_search_titles_only |
|
249 | 288 | get :index, :params => {:id => 1, :q => 'recipe', :titles_only => '1'} |
|
250 | assert_equal true, assigns(:titles_only) | |
|
251 | results = assigns(:results) | |
|
252 | assert_not_nil results | |
|
253 | assert_equal 2, results.size | |
|
289 | assert_response :success | |
|
290 | ||
|
291 | assert_select 'input[name=titles_only][checked=checked]' | |
|
292 | assert_select '#search-results' do | |
|
293 | assert_select 'dt', 2 | |
|
294 | end | |
|
254 | 295 | end |
|
255 | 296 | |
|
256 | 297 | def test_search_content |
|
257 | 298 | Issue.where(:id => 1).update_all("description = 'This is a searchkeywordinthecontent'") |
|
258 | 299 | |
|
259 | 300 | get :index, :params => {:id => 1, :q => 'searchkeywordinthecontent', :titles_only => ''} |
|
260 | assert_equal false, assigns(:titles_only) | |
|
261 | results = assigns(:results) | |
|
262 | assert_not_nil results | |
|
263 | assert_equal 1, results.size | |
|
301 | assert_response :success | |
|
302 | ||
|
303 | assert_select 'input[name=titles_only]:not([checked])' | |
|
304 | assert_select '#search-results' do | |
|
305 | assert_select 'dt.issue', :text => / #1 / | |
|
306 | assert_select 'dt', 1 | |
|
307 | end | |
|
264 | 308 | end |
|
265 | 309 | |
|
266 | 310 | def test_search_with_pagination |
|
267 | issue = (0..24).map {Issue.generate! :subject => 'search_with_limited_results'}.reverse | |
|
311 | issues = (0..24).map {Issue.generate! :subject => 'search_with_limited_results'}.reverse | |
|
268 | 312 | |
|
269 | 313 | get :index, :params => {:q => 'search_with_limited_results'} |
|
270 | 314 | assert_response :success |
|
271 | assert_equal issue[0..9], assigns(:results) | |
|
315 | issues[0..9].each do |issue| | |
|
316 | assert_select '#search-results dt.issue', :text => / ##{issue.id} / | |
|
317 | end | |
|
272 | 318 | |
|
273 | 319 | get :index, :params => {:q => 'search_with_limited_results', :page => 2} |
|
274 | 320 | assert_response :success |
|
275 | assert_equal issue[10..19], assigns(:results) | |
|
321 | issues[10..19].each do |issue| | |
|
322 | assert_select '#search-results dt.issue', :text => / ##{issue.id} / | |
|
323 | end | |
|
276 | 324 | |
|
277 | 325 | get :index, :params => {:q => 'search_with_limited_results', :page => 3} |
|
278 | 326 | assert_response :success |
|
279 | assert_equal issue[20..24], assigns(:results) | |
|
327 | issues[20..24].each do |issue| | |
|
328 | assert_select '#search-results dt.issue', :text => / ##{issue.id} / | |
|
329 | end | |
|
280 | 330 | |
|
281 | 331 | get :index, :params => {:q => 'search_with_limited_results', :page => 4} |
|
282 | 332 | assert_response :success |
|
283 | assert_equal [], assigns(:results) | |
|
333 | assert_select '#search-results dt', 0 | |
|
284 | 334 | end |
|
285 | 335 | |
|
286 | 336 | def test_search_with_invalid_project_id |
|
287 | 337 | get :index, :params => {:id => 195, :q => 'recipe'} |
|
288 | 338 | assert_response 404 |
|
289 | assert_nil assigns(:results) | |
|
290 | 339 | end |
|
291 | 340 | |
|
292 | 341 | def test_quick_jump_to_issue |
@@ -297,18 +346,25 class SearchControllerTest < Redmine::ControllerTest | |||
|
297 | 346 | # issue of a private project |
|
298 | 347 | get :index, :params => {:q => "4"} |
|
299 | 348 | assert_response :success |
|
300 | assert_template 'index' | |
|
301 | 349 | end |
|
302 | 350 | |
|
303 | 351 | def test_large_integer |
|
304 | 352 | get :index, :params => {:q => '4615713488'} |
|
305 | 353 | assert_response :success |
|
306 | assert_template 'index' | |
|
307 | 354 | end |
|
308 | 355 | |
|
309 | 356 | def test_tokens_with_quotes |
|
310 | get :index, :params => {:id => 1, :q => '"good bye" hello "bye bye"'} | |
|
311 | assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens) | |
|
357 | issue1 = Issue.generate! :subject => 'say hello' | |
|
358 | issue2 = Issue.generate! :subject => 'say good bye' | |
|
359 | issue3 = Issue.generate! :subject => 'say goodbye' | |
|
360 | ||
|
361 | get :index, :params => {:q => '"good bye" hello "bye bye"', :all_words => ''} | |
|
362 | assert_response :success | |
|
363 | assert_select '#search-results' do | |
|
364 | assert_select 'dt.issue a', :text => / ##{issue1.id} / | |
|
365 | assert_select 'dt.issue a', :text => / ##{issue2.id} / | |
|
366 | assert_select 'dt.issue a', :text => / ##{issue3.id} /, :count => 0 | |
|
367 | end | |
|
312 | 368 | end |
|
313 | 369 | |
|
314 | 370 | def test_results_should_be_escaped_once |
@@ -68,9 +68,9 class SearchCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
|
68 | 68 | assert_response :success |
|
69 | 69 | # we should get a result only if the custom field is visible |
|
70 | 70 | if fields.include?(field) |
|
71 | assert_equal 1, assigns(:results).size | |
|
71 | assert_select '#search-results dt', 1 | |
|
72 | 72 | else |
|
73 | assert_equal 0, assigns(:results).size | |
|
73 | assert_select '#search-results dt', 0 | |
|
74 | 74 | end |
|
75 | 75 | end |
|
76 | 76 | end |
@@ -34,13 +34,13 class SettingsControllerTest < Redmine::ControllerTest | |||
|
34 | 34 | def test_index |
|
35 | 35 | get :index |
|
36 | 36 | assert_response :success |
|
37 | assert_template 'edit' | |
|
37 | ||
|
38 | assert_select 'input[name=?][value=?]', 'settings[app_title]', Setting.app_title | |
|
38 | 39 | end |
|
39 | 40 | |
|
40 | 41 | def test_get_edit |
|
41 | 42 | get :edit |
|
42 | 43 | assert_response :success |
|
43 | assert_template 'edit' | |
|
44 | 44 | |
|
45 | 45 | assert_select 'input[name=?][value=""]', 'settings[enabled_scm][]' |
|
46 | 46 | end |
@@ -195,7 +195,7 class SettingsControllerTest < Redmine::ControllerTest | |||
|
195 | 195 | |
|
196 | 196 | get :plugin, :params => {:id => 'foo'} |
|
197 | 197 | assert_response :success |
|
198 | assert_template 'plugin' | |
|
198 | ||
|
199 | 199 | assert_select 'form[action="/settings/plugin/foo"]' do |
|
200 | 200 | assert_select 'input[name=?][value=?]', 'settings[sample_setting]', 'Plugin setting value' |
|
201 | 201 | end |
@@ -37,14 +37,12 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
37 | 37 | def test_report_at_project_level |
|
38 | 38 | get :report, :params => {:project_id => 'ecookbook'} |
|
39 | 39 | assert_response :success |
|
40 | assert_template 'report' | |
|
41 | 40 | assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries/report' |
|
42 | 41 | end |
|
43 | 42 | |
|
44 | 43 | def test_report_all_projects |
|
45 | 44 | get :report |
|
46 | 45 | assert_response :success |
|
47 | assert_template 'report' | |
|
48 | 46 | assert_select 'form#query_form[action=?]', '/time_entries/report' |
|
49 | 47 | end |
|
50 | 48 | |
@@ -60,42 +58,32 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
60 | 58 | def test_report_all_projects_one_criteria |
|
61 | 59 | get :report, :params => {:columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']} |
|
62 | 60 | assert_response :success |
|
63 | assert_template 'report' | |
|
64 | assert_not_nil assigns(:report) | |
|
65 | assert_equal "8.65", "%.2f" % assigns(:report).total_hours | |
|
61 | assert_select 'tr.total td:last', :text => '8.65' | |
|
66 | 62 | end |
|
67 | 63 | |
|
68 | 64 | def test_report_all_time |
|
69 | 65 | get :report, :params => {:project_id => 1, :criteria => ['project', 'issue']} |
|
70 | 66 | assert_response :success |
|
71 | assert_template 'report' | |
|
72 | assert_not_nil assigns(:report) | |
|
73 | assert_equal "162.90", "%.2f" % assigns(:report).total_hours | |
|
67 | assert_select 'tr.total td:last', :text => '162.90' | |
|
74 | 68 | end |
|
75 | 69 | |
|
76 | 70 | def test_report_all_time_by_day |
|
77 | 71 | get :report, :params => {:project_id => 1, :criteria => ['project', 'issue'], :columns => 'day'} |
|
78 | 72 | assert_response :success |
|
79 | assert_template 'report' | |
|
80 | assert_not_nil assigns(:report) | |
|
81 | assert_equal "162.90", "%.2f" % assigns(:report).total_hours | |
|
73 | assert_select 'tr.total td:last', :text => '162.90' | |
|
82 | 74 | assert_select 'th', :text => '2007-03-12' |
|
83 | 75 | end |
|
84 | 76 | |
|
85 | 77 | def test_report_one_criteria |
|
86 | 78 | get :report, :params => {:project_id => 1, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']} |
|
87 | 79 | assert_response :success |
|
88 | assert_template 'report' | |
|
89 | assert_not_nil assigns(:report) | |
|
90 | assert_equal "8.65", "%.2f" % assigns(:report).total_hours | |
|
80 | assert_select 'tr.total td:last', :text => '8.65' | |
|
91 | 81 | end |
|
92 | 82 | |
|
93 | 83 | def test_report_two_criteria |
|
94 | 84 | get :report, :params => {:project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criteria => ["user", "activity"]} |
|
95 | 85 | assert_response :success |
|
96 | assert_template 'report' | |
|
97 | assert_not_nil assigns(:report) | |
|
98 | assert_equal "162.90", "%.2f" % assigns(:report).total_hours | |
|
86 | assert_select 'tr.total td:last', :text => '162.90' | |
|
99 | 87 | end |
|
100 | 88 | |
|
101 | 89 | def test_report_custom_field_criteria_with_multiple_values_on_single_value_custom_field_should_not_fail |
@@ -123,9 +111,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
123 | 111 | def test_report_one_day |
|
124 | 112 | get :report, :params => {:project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"]} |
|
125 | 113 | assert_response :success |
|
126 | assert_template 'report' | |
|
127 | assert_not_nil assigns(:report) | |
|
128 | assert_equal "4.25", "%.2f" % assigns(:report).total_hours | |
|
114 | assert_select 'tr.total td:last', :text => '4.25' | |
|
129 | 115 | end |
|
130 | 116 | |
|
131 | 117 | def test_report_by_week_should_use_commercial_year |
@@ -157,7 +143,6 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
157 | 143 | def test_report_should_propose_association_custom_fields |
|
158 | 144 | get :report |
|
159 | 145 | assert_response :success |
|
160 | assert_template 'report' | |
|
161 | 146 | |
|
162 | 147 | assert_select 'select[name=?]', 'criteria[]' do |
|
163 | 148 | assert_select 'option[value=cf_1]', {:text => 'Database'}, 'Issue custom field not found' |
@@ -169,10 +154,8 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
169 | 154 | def test_report_with_association_custom_fields |
|
170 | 155 | get :report, :params => {:criteria => ['cf_1', 'cf_3', 'cf_7']} |
|
171 | 156 | assert_response :success |
|
172 | assert_template 'report' | |
|
173 | assert_not_nil assigns(:report) | |
|
174 | assert_equal 3, assigns(:report).criteria.size | |
|
175 | assert_equal "162.90", "%.2f" % assigns(:report).total_hours | |
|
157 | ||
|
158 | assert_select 'tr.total td:last', :text => '162.90' | |
|
176 | 159 | |
|
177 | 160 | # Custom fields columns |
|
178 | 161 | assert_select 'th', :text => 'Database' |
@@ -189,15 +172,14 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
189 | 172 | def test_report_one_criteria_no_result |
|
190 | 173 | get :report, :params => {:project_id => 1, :columns => 'week', :from => "1998-04-01", :to => "1998-04-30", :criteria => ['project']} |
|
191 | 174 | assert_response :success |
|
192 | assert_template 'report' | |
|
193 | assert_not_nil assigns(:report) | |
|
194 | assert_equal "0.00", "%.2f" % assigns(:report).total_hours | |
|
175 | ||
|
176 | assert_select '.nodata' | |
|
195 | 177 | end |
|
196 | 178 | |
|
197 | 179 | def test_report_status_criterion |
|
198 | 180 | get :report, :params => {:project_id => 1, :criteria => ['status']} |
|
199 | 181 | assert_response :success |
|
200 | assert_template 'report' | |
|
182 | ||
|
201 | 183 | assert_select 'th', :text => 'Status' |
|
202 | 184 | assert_select 'td', :text => 'New' |
|
203 | 185 | end |
@@ -32,7 +32,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
32 | 32 | @request.session[:user_id] = 3 |
|
33 | 33 | get :new |
|
34 | 34 | assert_response :success |
|
35 | assert_template 'new' | |
|
35 | ||
|
36 | 36 | assert_select 'input[name=?][type=hidden]', 'project_id', 0 |
|
37 | 37 | assert_select 'input[name=?][type=hidden]', 'issue_id', 0 |
|
38 | 38 | assert_select 'select[name=?]', 'time_entry[project_id]' do |
@@ -45,7 +45,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
45 | 45 | @request.session[:user_id] = 3 |
|
46 | 46 | get :new, :params => {:project_id => 1} |
|
47 | 47 | assert_response :success |
|
48 | assert_template 'new' | |
|
48 | ||
|
49 | 49 | assert_select 'input[name=?][type=hidden]', 'project_id' |
|
50 | 50 | assert_select 'input[name=?][type=hidden]', 'issue_id', 0 |
|
51 | 51 | assert_select 'select[name=?]', 'time_entry[project_id]', 0 |
@@ -55,7 +55,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
55 | 55 | @request.session[:user_id] = 3 |
|
56 | 56 | get :new, :params => {:issue_id => 2} |
|
57 | 57 | assert_response :success |
|
58 | assert_template 'new' | |
|
58 | ||
|
59 | 59 | assert_select 'input[name=?][type=hidden]', 'project_id', 0 |
|
60 | 60 | assert_select 'input[name=?][type=hidden]', 'issue_id' |
|
61 | 61 | assert_select 'select[name=?]', 'time_entry[project_id]', 0 |
@@ -65,7 +65,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
65 | 65 | @request.session[:user_id] = 3 |
|
66 | 66 | get :new, :params => {:time_entry => {:project_id => '1'}} |
|
67 | 67 | assert_response :success |
|
68 | assert_template 'new' | |
|
68 | ||
|
69 | 69 | assert_select 'select[name=?]', 'time_entry[project_id]' do |
|
70 | 70 | assert_select 'option[value="1"][selected=selected]' |
|
71 | 71 | end |
@@ -106,7 +106,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
106 | 106 | @request.session[:user_id] = 2 |
|
107 | 107 | get :edit, :params => {:id => 2, :project_id => nil} |
|
108 | 108 | assert_response :success |
|
109 | assert_template 'edit' | |
|
109 | ||
|
110 | 110 | assert_select 'form[action=?]', '/time_entries/2' |
|
111 | 111 | end |
|
112 | 112 | |
@@ -118,7 +118,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
118 | 118 | @request.session[:user_id] = 1 |
|
119 | 119 | get :edit, :params => {:project_id => 1, :id => 1} |
|
120 | 120 | assert_response :success |
|
121 | assert_template 'edit' | |
|
121 | ||
|
122 | 122 | # Blank option since nothing is pre-selected |
|
123 | 123 | assert_select 'option', :text => '--- Please select ---' |
|
124 | 124 | end |
@@ -341,7 +341,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
341 | 341 | post :create, :params => {:time_entry => {:issue_id => ''}} |
|
342 | 342 | |
|
343 | 343 | assert_response :success |
|
344 | assert_template 'new' | |
|
344 | assert_select_error /Project cannot be blank/ | |
|
345 | 345 | end |
|
346 | 346 | |
|
347 | 347 | def test_create_with_failure |
@@ -356,7 +356,6 class TimelogControllerTest < Redmine::ControllerTest | |||
|
356 | 356 | } |
|
357 | 357 | } |
|
358 | 358 | assert_response :success |
|
359 | assert_template 'new' | |
|
360 | 359 | end |
|
361 | 360 | |
|
362 | 361 | def test_create_without_project |
@@ -393,7 +392,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
393 | 392 | end |
|
394 | 393 | |
|
395 | 394 | assert_response :success |
|
396 | assert assigns(:time_entry).errors[:issue_id].present? | |
|
395 | assert_select_error /Issue is invalid/ | |
|
397 | 396 | end |
|
398 | 397 | |
|
399 | 398 | def test_create_without_project_should_deny_without_permission |
@@ -484,8 +483,8 class TimelogControllerTest < Redmine::ControllerTest | |||
|
484 | 483 | :issue_id => '5' |
|
485 | 484 | } |
|
486 | 485 | } |
|
487 |
assert_response |
|
|
488 | assert_include "Issue is invalid", assigns(:time_entry).errors.full_messages | |
|
486 | assert_response :success | |
|
487 | assert_select_error /Issue is invalid/ | |
|
489 | 488 | end |
|
490 | 489 | |
|
491 | 490 | def test_get_bulk_edit |
@@ -493,7 +492,6 class TimelogControllerTest < Redmine::ControllerTest | |||
|
493 | 492 | |
|
494 | 493 | get :bulk_edit, :params => {:ids => [1, 2]} |
|
495 | 494 | assert_response :success |
|
496 | assert_template 'bulk_edit' | |
|
497 | 495 | |
|
498 | 496 | assert_select 'ul#bulk-selection' do |
|
499 | 497 | assert_select 'li', 2 |
@@ -517,7 +515,6 class TimelogControllerTest < Redmine::ControllerTest | |||
|
517 | 515 | |
|
518 | 516 | get :bulk_edit, :params => {:ids => [1, 2, 6]} |
|
519 | 517 | assert_response :success |
|
520 | assert_template 'bulk_edit' | |
|
521 | 518 | end |
|
522 | 519 | |
|
523 | 520 | def test_bulk_edit_with_edit_own_time_entries_permission |
@@ -664,26 +661,28 class TimelogControllerTest < Redmine::ControllerTest | |||
|
664 | 661 | @request.session[:user_id] = 2 |
|
665 | 662 | get :index |
|
666 | 663 | assert_response :success |
|
667 | assert_template 'index' | |
|
664 | ||
|
668 | 665 | assert_select 'a[href=?]', '/time_entries/new', :text => /Log time/ |
|
669 | 666 | end |
|
670 | 667 | |
|
671 | 668 | def test_index_my_spent_time |
|
672 | 669 | @request.session[:user_id] = 2 |
|
673 | get :index, :params => {:user_id => 'me'} | |
|
670 | get :index, :params => {:user_id => 'me', :c => ['user']} | |
|
674 | 671 | assert_response :success |
|
675 | assert_template 'index' | |
|
676 | assert assigns(:entries).all? {|entry| entry.user_id == 2} | |
|
672 | ||
|
673 | users = css_select('table.time-entries tbody td.user').map(&:text).uniq | |
|
674 | assert_equal ["John Smith"], users | |
|
677 | 675 | end |
|
678 | 676 | |
|
679 | 677 | def test_index_at_project_level |
|
680 | get :index, :params => {:project_id => 'ecookbook'} | |
|
678 | get :index, :params => {:project_id => 'ecookbook', :c => ['project']} | |
|
681 | 679 | assert_response :success |
|
682 | assert_template 'index' | |
|
683 | assert_not_nil assigns(:entries) | |
|
684 | assert_equal 4, assigns(:entries).size | |
|
680 | ||
|
681 | assert_select 'tr.time-entry', 4 | |
|
682 | ||
|
685 | 683 | # project and subproject |
|
686 | assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort | |
|
684 | projects = css_select('table.time-entries tbody td.project').map(&:text).uniq.sort | |
|
685 | assert_equal ["eCookbook", "eCookbook Subproject 1"], projects | |
|
687 | 686 | |
|
688 | 687 | assert_select '.total-for-hours', :text => 'Hours: 162.90' |
|
689 | 688 | assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries' |
@@ -693,10 +692,11 class TimelogControllerTest < Redmine::ControllerTest | |||
|
693 | 692 | entry = TimeEntry.generate!(:project => Project.find(3)) |
|
694 | 693 | |
|
695 | 694 | with_settings :display_subprojects_issues => '0' do |
|
696 | get :index, :params => {:project_id => 'ecookbook'} | |
|
695 | get :index, :params => {:project_id => 'ecookbook', :c => ['project']} | |
|
697 | 696 | assert_response :success |
|
698 | assert_template 'index' | |
|
699 | assert_not_include entry, assigns(:entries) | |
|
697 | ||
|
698 | projects = css_select('table.time-entries tbody td.project').map(&:text).uniq.sort | |
|
699 | assert_equal ["eCookbook"], projects | |
|
700 | 700 | end |
|
701 | 701 | end |
|
702 | 702 | |
@@ -704,10 +704,11 class TimelogControllerTest < Redmine::ControllerTest | |||
|
704 | 704 | entry = TimeEntry.generate!(:project => Project.find(3)) |
|
705 | 705 | |
|
706 | 706 | with_settings :display_subprojects_issues => '0' do |
|
707 | get :index, :params => {:project_id => 'ecookbook', :subproject_id => 3} | |
|
707 | get :index, :params => {:project_id => 'ecookbook', :c => ['project'], :subproject_id => 3} | |
|
708 | 708 | assert_response :success |
|
709 | assert_template 'index' | |
|
710 | assert_include entry, assigns(:entries) | |
|
709 | ||
|
710 | projects = css_select('table.time-entries tbody td.project').map(&:text).uniq.sort | |
|
711 | assert_equal ["eCookbook", "eCookbook Subproject 1"], projects | |
|
711 | 712 | end |
|
712 | 713 | end |
|
713 | 714 | |
@@ -740,10 +741,8 class TimelogControllerTest < Redmine::ControllerTest | |||
|
740 | 741 | :v => {'spent_on' => ['2007-03-20', '2007-04-30']} |
|
741 | 742 | } |
|
742 | 743 | assert_response :success |
|
743 | assert_template 'index' | |
|
744 | assert_not_nil assigns(:entries) | |
|
745 | assert_equal 3, assigns(:entries).size | |
|
746 | 744 | |
|
745 | assert_select 'tr.time-entry', 3 | |
|
747 | 746 | assert_select '.total-for-hours', :text => 'Hours: 12.90' |
|
748 | 747 | assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries' |
|
749 | 748 | end |
@@ -755,10 +754,8 class TimelogControllerTest < Redmine::ControllerTest | |||
|
755 | 754 | :to => '2007-04-30' |
|
756 | 755 | } |
|
757 | 756 | assert_response :success |
|
758 | assert_template 'index' | |
|
759 | assert_not_nil assigns(:entries) | |
|
760 | assert_equal 3, assigns(:entries).size | |
|
761 | 757 | |
|
758 | assert_select 'tr.time-entry', 3 | |
|
762 | 759 | assert_select '.total-for-hours', :text => 'Hours: 12.90' |
|
763 | 760 | assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries' |
|
764 | 761 | end |
@@ -787,7 +784,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
787 | 784 | :v => {'spent_on' => ['2012-06-15', '2012-06-16']} |
|
788 | 785 | } |
|
789 | 786 | assert_response :success |
|
790 | assert_equal [t2, t1, t3], assigns(:entries) | |
|
787 | assert_equal [t2, t1, t3].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')} | |
|
791 | 788 | |
|
792 | 789 | get :index, :params => { |
|
793 | 790 | :project_id => 1, |
@@ -797,7 +794,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
797 | 794 | :sort => 'spent_on' |
|
798 | 795 | } |
|
799 | 796 | assert_response :success |
|
800 | assert_equal [t3, t1, t2], assigns(:entries) | |
|
797 | assert_equal [t3, t1, t2].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')} | |
|
801 | 798 | end |
|
802 | 799 | |
|
803 | 800 | def test_index_with_filter_on_issue_custom_field |
@@ -810,7 +807,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
810 | 807 | :v => {'issue.cf_2' => ['filter_on_issue_custom_field']} |
|
811 | 808 | } |
|
812 | 809 | assert_response :success |
|
813 | assert_equal [entry], assigns(:entries) | |
|
810 | assert_equal [entry].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')} | |
|
814 | 811 | end |
|
815 | 812 | |
|
816 | 813 | def test_index_with_issue_custom_field_column |
@@ -821,7 +818,6 class TimelogControllerTest < Redmine::ControllerTest | |||
|
821 | 818 | :c => %w(project spent_on issue comments hours issue.cf_2) |
|
822 | 819 | } |
|
823 | 820 | assert_response :success |
|
824 | assert_include :'issue.cf_2', assigns(:query).column_names | |
|
825 | 821 | assert_select 'td.issue_cf_2', :text => 'filter_on_issue_custom_field' |
|
826 | 822 | end |
|
827 | 823 | |
@@ -834,7 +830,6 class TimelogControllerTest < Redmine::ControllerTest | |||
|
834 | 830 | :c => ["hours", field_name] |
|
835 | 831 | } |
|
836 | 832 | assert_response :success |
|
837 | assert_include field_name.to_sym, assigns(:query).column_names | |
|
838 | 833 | assert_select "td.#{field_name}", :text => 'CF Value' |
|
839 | 834 | end |
|
840 | 835 | |
@@ -850,13 +845,12 class TimelogControllerTest < Redmine::ControllerTest | |||
|
850 | 845 | :sort => field_name |
|
851 | 846 | } |
|
852 | 847 | assert_response :success |
|
853 | assert_include field_name.to_sym, assigns(:query).column_names | |
|
854 | 848 | assert_select "th a.sort", :text => 'String Field' |
|
855 | 849 | |
|
856 | 850 | # Make sure that values are properly sorted |
|
857 | values = assigns(:entries).map {|e| e.custom_field_value(field)}.compact | |
|
858 | assert_equal 3, values.size | |
|
851 | values = css_select("td.#{field_name}").map(&:text).reject(&:blank?) | |
|
859 | 852 | assert_equal values.sort, values |
|
853 | assert_equal 3, values.size | |
|
860 | 854 | end |
|
861 | 855 | |
|
862 | 856 | def test_index_with_query |
@@ -874,8 +868,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
874 | 868 | get :index, :params => {:project_id => 1, :format => 'atom'} |
|
875 | 869 | assert_response :success |
|
876 | 870 | assert_equal 'application/atom+xml', @response.content_type |
|
877 | assert_not_nil assigns(:items) | |
|
878 | assert assigns(:items).first.is_a?(TimeEntry) | |
|
871 | assert_select 'entry > title', :text => /7\.65 hours/ | |
|
879 | 872 | end |
|
880 | 873 | |
|
881 | 874 | def test_index_at_project_level_should_include_csv_export_dialog |
@@ -122,7 +122,9 class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
|
122 | 122 | assert_select 'td', :text => 'ValueB', :count => 0 |
|
123 | 123 | assert_select 'td', {:text => 'ValueC'}, "ValueC not found in:\n#{response.body}" |
|
124 | 124 | |
|
125 | get :index, :params => {:set_filter => '1', "issue.cf_#{@field2.id}" => '*'} | |
|
126 | assert_equal %w(ValueA ValueC), assigns(:entries).map{|i| i.issue.custom_field_value(@field2)}.sort | |
|
125 | get :index, :params => {:set_filter => '1', "issue.cf_#{@field2.id}" => '*', :c => ["issue.cf_#{@field2.id}"]} | |
|
126 | assert_select 'td', :text => "ValueA" | |
|
127 | assert_select 'td', :text => "ValueC" | |
|
128 | assert_select 'td', :text => "ValueB", :count => 0 | |
|
127 | 129 | end |
|
128 | 130 | end |
@@ -28,7 +28,7 class TrackersControllerTest < Redmine::ControllerTest | |||
|
28 | 28 | def test_index |
|
29 | 29 | get :index |
|
30 | 30 | assert_response :success |
|
31 | assert_template 'index' | |
|
31 | assert_select 'table.trackers' | |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | def test_index_by_anonymous_should_redirect_to_login_form |
@@ -46,7 +46,7 class TrackersControllerTest < Redmine::ControllerTest | |||
|
46 | 46 | def test_new |
|
47 | 47 | get :new |
|
48 | 48 | assert_response :success |
|
49 | assert_template 'new' | |
|
49 | assert_select 'input[name=?]', 'tracker[name]' | |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | def test_create |
@@ -112,7 +112,6 class TrackersControllerTest < Redmine::ControllerTest | |||
|
112 | 112 | } |
|
113 | 113 | end |
|
114 | 114 | assert_response :success |
|
115 | assert_template 'new' | |
|
116 | 115 | assert_select_error /name cannot be blank/i |
|
117 | 116 | end |
|
118 | 117 | |
@@ -121,7 +120,6 class TrackersControllerTest < Redmine::ControllerTest | |||
|
121 | 120 | |
|
122 | 121 | get :edit, :params => {:id => 1} |
|
123 | 122 | assert_response :success |
|
124 | assert_template 'edit' | |
|
125 | 123 | |
|
126 | 124 | assert_select 'input[name=?][value="1"][checked=checked]', 'tracker[project_ids][]' |
|
127 | 125 | assert_select 'input[name=?][value="2"]:not([checked])', 'tracker[project_ids][]' |
@@ -136,7 +134,6 class TrackersControllerTest < Redmine::ControllerTest | |||
|
136 | 134 | |
|
137 | 135 | get :edit, :params => {:id => 1} |
|
138 | 136 | assert_response :success |
|
139 | assert_template 'edit' | |
|
140 | 137 | |
|
141 | 138 | assert_select 'input[name=?][value=assigned_to_id][checked=checked]', 'tracker[core_fields][]' |
|
142 | 139 | assert_select 'input[name=?][value=fixed_version_id][checked=checked]', 'tracker[core_fields][]' |
@@ -186,7 +183,7 class TrackersControllerTest < Redmine::ControllerTest | |||
|
186 | 183 | def test_update_with_failure |
|
187 | 184 | put :update, :params => {:id => 1, :tracker => { :name => '' }} |
|
188 | 185 | assert_response :success |
|
189 | assert_template 'edit' | |
|
186 | ||
|
190 | 187 | assert_select_error /name cannot be blank/i |
|
191 | 188 | end |
|
192 | 189 | |
@@ -216,7 +213,6 class TrackersControllerTest < Redmine::ControllerTest | |||
|
216 | 213 | def test_get_fields |
|
217 | 214 | get :fields |
|
218 | 215 | assert_response :success |
|
219 | assert_template 'fields' | |
|
220 | 216 | |
|
221 | 217 | assert_select 'form' do |
|
222 | 218 | assert_select 'input[type=checkbox][name=?][value=assigned_to_id]', 'trackers[1][core_fields][]' |
@@ -35,37 +35,30 class UsersControllerTest < Redmine::ControllerTest | |||
|
35 | 35 | def test_index |
|
36 | 36 | get :index |
|
37 | 37 | assert_response :success |
|
38 | assert_template 'index' | |
|
39 | assert_not_nil assigns(:users) | |
|
40 | # active users only | |
|
41 | assert_nil assigns(:users).detect {|u| !u.active?} | |
|
38 | assert_select 'table.users' | |
|
39 | assert_select 'tr.user.active' | |
|
40 | assert_select 'tr.user.locked', 0 | |
|
42 | 41 | end |
|
43 | 42 | |
|
44 | 43 | def test_index_with_status_filter |
|
45 | 44 | get :index, :params => {:status => 3} |
|
46 | 45 | assert_response :success |
|
47 | assert_template 'index' | |
|
48 | assert_not_nil assigns(:users) | |
|
49 | assert_equal [3], assigns(:users).map(&:status).uniq | |
|
46 | assert_select 'tr.user.active', 0 | |
|
47 | assert_select 'tr.user.locked' | |
|
50 | 48 | end |
|
51 | 49 | |
|
52 | 50 | def test_index_with_name_filter |
|
53 | 51 | get :index, :params => {:name => 'john'} |
|
54 | 52 | assert_response :success |
|
55 | assert_template 'index' | |
|
56 | users = assigns(:users) | |
|
57 | assert_not_nil users | |
|
58 | assert_equal 1, users.size | |
|
59 | assert_equal 'John', users.first.firstname | |
|
53 | assert_select 'tr.user td.username', :text => 'jsmith' | |
|
54 | assert_select 'tr.user', 1 | |
|
60 | 55 | end |
|
61 | 56 | |
|
62 | 57 | def test_index_with_group_filter |
|
63 | 58 | get :index, :params => {:group_id => '10'} |
|
64 | 59 | assert_response :success |
|
65 | assert_template 'index' | |
|
66 | users = assigns(:users) | |
|
67 | assert users.any? | |
|
68 | assert_equal([], (users - Group.find(10).users)) | |
|
60 | ||
|
61 | assert_select 'tr.user', Group.find(10).users.count | |
|
69 | 62 | assert_select 'select[name=group_id]' do |
|
70 | 63 | assert_select 'option[value="10"][selected=selected]' |
|
71 | 64 | end |
@@ -75,8 +68,14 class UsersControllerTest < Redmine::ControllerTest | |||
|
75 | 68 | @request.session[:user_id] = nil |
|
76 | 69 | get :show, :params => {:id => 2} |
|
77 | 70 | assert_response :success |
|
78 | assert_template 'show' | |
|
79 | assert_not_nil assigns(:user) | |
|
71 | assert_select 'h2', :text => /John Smith/ | |
|
72 | end | |
|
73 | ||
|
74 | def test_show_should_display_visible_custom_fields | |
|
75 | @request.session[:user_id] = nil | |
|
76 | UserCustomField.find_by_name('Phone number').update_attribute :visible, true | |
|
77 | get :show, :params => {:id => 2} | |
|
78 | assert_response :success | |
|
80 | 79 | |
|
81 | 80 | assert_select 'li', :text => /Phone number/ |
|
82 | 81 | end |
@@ -86,8 +85,6 class UsersControllerTest < Redmine::ControllerTest | |||
|
86 | 85 | UserCustomField.find_by_name('Phone number').update_attribute :visible, false |
|
87 | 86 | get :show, :params => {:id => 2} |
|
88 | 87 | assert_response :success |
|
89 | assert_template 'show' | |
|
90 | assert_not_nil assigns(:user) | |
|
91 | 88 | |
|
92 | 89 | assert_select 'li', :text => /Phone number/, :count => 0 |
|
93 | 90 | end |
@@ -113,7 +110,7 class UsersControllerTest < Redmine::ControllerTest | |||
|
113 | 110 | @request.session[:user_id] = 1 |
|
114 | 111 | get :show, :params => {:id => 5} |
|
115 | 112 | assert_response 200 |
|
116 | assert_not_nil assigns(:user) | |
|
113 | assert_select 'h2', :text => /Dave2 Lopper2/ | |
|
117 | 114 | end |
|
118 | 115 | |
|
119 | 116 | def test_show_user_who_is_not_visible_should_return_404 |
@@ -129,10 +126,9 class UsersControllerTest < Redmine::ControllerTest | |||
|
129 | 126 | @request.session[:user_id] = 1 |
|
130 | 127 | get :show, :params => {:id => 2} |
|
131 | 128 | assert_response :success |
|
132 | memberships = assigns(:memberships) | |
|
133 | assert_not_nil memberships | |
|
134 | project_ids = memberships.map(&:project_id) | |
|
135 | assert project_ids.include?(2) #private project admin can see | |
|
129 | ||
|
130 | # membership of private project admin can see | |
|
131 | assert_select 'li a', :text => "OnlineStore" | |
|
136 | 132 | end |
|
137 | 133 | |
|
138 | 134 | def test_show_current_should_require_authentication |
@@ -145,15 +141,13 class UsersControllerTest < Redmine::ControllerTest | |||
|
145 | 141 | @request.session[:user_id] = 2 |
|
146 | 142 | get :show, :params => {:id => 'current'} |
|
147 | 143 | assert_response :success |
|
148 | assert_template 'show' | |
|
149 | assert_equal User.find(2), assigns(:user) | |
|
144 | assert_select 'h2', :text => /John Smith/ | |
|
150 | 145 | end |
|
151 | 146 | |
|
152 | 147 | def test_new |
|
153 | 148 | get :new |
|
154 | 149 | assert_response :success |
|
155 | assert_template :new | |
|
156 | assert assigns(:user) | |
|
150 | assert_select 'input[name=?]', 'user[login]' | |
|
157 | 151 | end |
|
158 | 152 | |
|
159 | 153 | def test_create |
@@ -266,7 +260,7 class UsersControllerTest < Redmine::ControllerTest | |||
|
266 | 260 | post :create, :params => {:user => {}} |
|
267 | 261 | end |
|
268 | 262 | assert_response :success |
|
269 | assert_template 'new' | |
|
263 | assert_select_error /Email cannot be blank/ | |
|
270 | 264 | end |
|
271 | 265 | |
|
272 | 266 | def test_create_with_failure_sould_preserve_preference |
@@ -283,7 +277,6 class UsersControllerTest < Redmine::ControllerTest | |||
|
283 | 277 | } |
|
284 | 278 | end |
|
285 | 279 | assert_response :success |
|
286 | assert_template 'new' | |
|
287 | 280 | |
|
288 | 281 | assert_select 'select#pref_time_zone option[selected=selected]', :text => /Paris/ |
|
289 | 282 | assert_select 'input#pref_no_self_notified[value="1"][checked=checked]' |
@@ -336,8 +329,7 class UsersControllerTest < Redmine::ControllerTest | |||
|
336 | 329 | def test_edit |
|
337 | 330 | get :edit, :params => {:id => 2} |
|
338 | 331 | assert_response :success |
|
339 | assert_template 'edit' | |
|
340 | assert_equal User.find(2), assigns(:user) | |
|
332 | assert_select 'input[name=?][value=?]', 'user[login]', 'jsmith' | |
|
341 | 333 | end |
|
342 | 334 | |
|
343 | 335 | def test_edit_registered_user |
@@ -371,7 +363,7 class UsersControllerTest < Redmine::ControllerTest | |||
|
371 | 363 | } |
|
372 | 364 | end |
|
373 | 365 | assert_response :success |
|
374 | assert_template 'edit' | |
|
366 | assert_select_error /First name cannot be blank/ | |
|
375 | 367 | end |
|
376 | 368 | |
|
377 | 369 | def test_update_with_group_ids_should_assign_groups |
@@ -476,7 +468,6 class UsersControllerTest < Redmine::ControllerTest | |||
|
476 | 468 | def test_update_notified_project |
|
477 | 469 | get :edit, :params => {:id => 2} |
|
478 | 470 | assert_response :success |
|
479 | assert_template 'edit' | |
|
480 | 471 | u = User.find(2) |
|
481 | 472 | assert_equal [1, 2, 5], u.projects.collect{|p| p.id}.sort |
|
482 | 473 | assert_equal [1, 2, 5], u.notified_projects_ids.sort |
@@ -29,12 +29,12 class VersionsControllerTest < Redmine::ControllerTest | |||
|
29 | 29 | def test_index |
|
30 | 30 | get :index, :params => {:project_id => 1} |
|
31 | 31 | assert_response :success |
|
32 | assert_template 'index' | |
|
33 | assert_not_nil assigns(:versions) | |
|
32 | ||
|
34 | 33 | # Version with no date set appears |
|
35 | assert assigns(:versions).include?(Version.find(3)) | |
|
34 | assert_select 'h3', :text => Version.find(3).name | |
|
36 | 35 | # Completed version doesn't appear |
|
37 | assert !assigns(:versions).include?(Version.find(1)) | |
|
36 | assert_select 'h3', :text => Version.find(1).name, :count => 0 | |
|
37 | ||
|
38 | 38 | # Context menu on issues |
|
39 | 39 | assert_select "script", :text => Regexp.new(Regexp.escape("contextMenuInit('/issues/context_menu')")) |
|
40 | 40 | assert_select "div#sidebar" do |
@@ -48,31 +48,33 class VersionsControllerTest < Redmine::ControllerTest | |||
|
48 | 48 | def test_index_with_completed_versions |
|
49 | 49 | get :index, :params => {:project_id => 1, :completed => 1} |
|
50 | 50 | assert_response :success |
|
51 | assert_template 'index' | |
|
52 | assert_not_nil assigns(:versions) | |
|
51 | ||
|
53 | 52 | # Version with no date set appears |
|
54 | assert assigns(:versions).include?(Version.find(3)) | |
|
53 | assert_select 'h3', :text => Version.find(3).name | |
|
55 | 54 | # Completed version appears |
|
56 | assert assigns(:versions).include?(Version.find(1)) | |
|
55 | assert_select 'h3', :text => Version.find(1).name | |
|
57 | 56 | end |
|
58 | 57 | |
|
59 | 58 | def test_index_with_tracker_ids |
|
59 | (1..3).each do |tracker_id| | |
|
60 | Issue.generate! :project_id => 1, :fixed_version_id => 3, :tracker_id => tracker_id | |
|
61 | end | |
|
60 | 62 | get :index, :params => {:project_id => 1, :tracker_ids => [1, 3]} |
|
61 | 63 | assert_response :success |
|
62 | assert_template 'index' | |
|
63 | assert_not_nil assigns(:issues_by_version) | |
|
64 | assert_nil assigns(:issues_by_version).values.flatten.detect {|issue| issue.tracker_id == 2} | |
|
64 | assert_select 'a.issue.tracker-1' | |
|
65 | assert_select 'a.issue.tracker-2', 0 | |
|
66 | assert_select 'a.issue.tracker-3' | |
|
65 | 67 | end |
|
66 | 68 | |
|
67 | 69 | def test_index_showing_subprojects_versions |
|
68 | 70 | @subproject_version = Version.create!(:project => Project.find(3), :name => "Subproject version") |
|
69 | 71 | get :index, :params => {:project_id => 1, :with_subprojects => 1} |
|
70 | 72 | assert_response :success |
|
71 | assert_template 'index' | |
|
72 | assert_not_nil assigns(:versions) | |
|
73 | 73 | |
|
74 | assert assigns(:versions).include?(Version.find(4)), "Shared version not found" | |
|
75 | assert assigns(:versions).include?(@subproject_version), "Subproject version not found" | |
|
74 | # Shared version | |
|
75 | assert_select 'h3', :text => Version.find(4).name | |
|
76 | # Subproject version | |
|
77 | assert_select 'h3', :text => /Subproject version/ | |
|
76 | 78 | end |
|
77 | 79 | |
|
78 | 80 | def test_index_should_prepend_shared_versions |
@@ -92,8 +94,6 class VersionsControllerTest < Redmine::ControllerTest | |||
|
92 | 94 | def test_show |
|
93 | 95 | get :show, :params => {:id => 2} |
|
94 | 96 | assert_response :success |
|
95 | assert_template 'show' | |
|
96 | assert_not_nil assigns(:version) | |
|
97 | 97 | |
|
98 | 98 | assert_select 'h2', :text => /1.0/ |
|
99 | 99 | end |
@@ -127,14 +127,13 class VersionsControllerTest < Redmine::ControllerTest | |||
|
127 | 127 | @request.session[:user_id] = 2 |
|
128 | 128 | get :new, :params => {:project_id => '1'} |
|
129 | 129 | assert_response :success |
|
130 | assert_template 'new' | |
|
130 | assert_select 'input[name=?]', 'version[name]' | |
|
131 | 131 | end |
|
132 | 132 | |
|
133 | 133 | def test_new_from_issue_form |
|
134 | 134 | @request.session[:user_id] = 2 |
|
135 | 135 | xhr :get, :new, :params => {:project_id => '1'} |
|
136 | 136 | assert_response :success |
|
137 | assert_template 'new' | |
|
138 | 137 | assert_equal 'text/javascript', response.content_type |
|
139 | 138 | end |
|
140 | 139 | |
@@ -159,7 +158,6 class VersionsControllerTest < Redmine::ControllerTest | |||
|
159 | 158 | assert_equal 1, version.project_id |
|
160 | 159 | |
|
161 | 160 | assert_response :success |
|
162 | assert_template 'create' | |
|
163 | 161 | assert_equal 'text/javascript', response.content_type |
|
164 | 162 | assert_include 'test_add_version_from_issue_form', response.body |
|
165 | 163 | end |
@@ -170,7 +168,6 class VersionsControllerTest < Redmine::ControllerTest | |||
|
170 | 168 | xhr :post, :create, :params => {:project_id => '1', :version => {:name => ''}} |
|
171 | 169 | end |
|
172 | 170 | assert_response :success |
|
173 | assert_template 'new' | |
|
174 | 171 | assert_equal 'text/javascript', response.content_type |
|
175 | 172 | end |
|
176 | 173 | |
@@ -178,7 +175,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
178 | 175 | @request.session[:user_id] = 2 |
|
179 | 176 | get :edit, :params => {:id => 2} |
|
180 | 177 | assert_response :success |
|
181 | assert_template 'edit' | |
|
178 | assert_select 'input[name=?][value=?]', 'version[name]', Version.find(2).name | |
|
182 | 179 | end |
|
183 | 180 | |
|
184 | 181 | def test_close_completed |
@@ -216,7 +213,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
216 | 213 | } |
|
217 | 214 | } |
|
218 | 215 | assert_response :success |
|
219 | assert_template 'edit' | |
|
216 | assert_select_error /Name cannot be blank/ | |
|
220 | 217 | end |
|
221 | 218 | |
|
222 | 219 | def test_destroy |
@@ -243,15 +240,11 class VersionsControllerTest < Redmine::ControllerTest | |||
|
243 | 240 | def test_issue_status_by |
|
244 | 241 | xhr :get, :status_by, :params => {:id => 2} |
|
245 | 242 | assert_response :success |
|
246 | assert_template 'status_by' | |
|
247 | assert_template '_issue_counts' | |
|
248 | 243 | end |
|
249 | 244 | |
|
250 | 245 | def test_issue_status_by_status |
|
251 | 246 | xhr :get, :status_by, :params => {:id => 2, :status_by => 'status'} |
|
252 | 247 | assert_response :success |
|
253 | assert_template 'status_by' | |
|
254 | assert_template '_issue_counts' | |
|
255 | 248 | assert_include 'Assigned', response.body |
|
256 | 249 | assert_include 'Closed', response.body |
|
257 | 250 | end |
@@ -144,7 +144,6 class WatchersControllerTest < Redmine::ControllerTest | |||
|
144 | 144 | @request.session[:user_id] = 2 |
|
145 | 145 | xhr :get, :new, :params => {:project_id => 1} |
|
146 | 146 | assert_response :success |
|
147 | assert_equal Project.find(1), assigns(:project) | |
|
148 | 147 | assert_match /ajax-modal/, response.body |
|
149 | 148 | end |
|
150 | 149 | |
@@ -152,7 +151,6 class WatchersControllerTest < Redmine::ControllerTest | |||
|
152 | 151 | @request.session[:user_id] = 2 |
|
153 | 152 | xhr :get, :new, :params => {:project_id => 'ecookbook'} |
|
154 | 153 | assert_response :success |
|
155 | assert_equal Project.find(1), assigns(:project) | |
|
156 | 154 | assert_match /ajax-modal/, response.body |
|
157 | 155 | end |
|
158 | 156 | |
@@ -266,16 +264,16 class WatchersControllerTest < Redmine::ControllerTest | |||
|
266 | 264 | def test_autocomplete_for_user_should_return_visible_users |
|
267 | 265 | Role.update_all :users_visibility => 'members_of_visible_projects' |
|
268 | 266 | |
|
269 | hidden = User.generate!(:lastname => 'autocomplete') | |
|
270 | visible = User.generate!(:lastname => 'autocomplete') | |
|
267 | hidden = User.generate!(:lastname => 'autocomplete_hidden') | |
|
268 | visible = User.generate!(:lastname => 'autocomplete_visible') | |
|
271 | 269 | User.add_to_project(visible, Project.find(1)) |
|
272 | 270 | |
|
273 | 271 | @request.session[:user_id] = 2 |
|
274 | 272 | xhr :get, :autocomplete_for_user, :params => {:q => 'autocomp', :project_id => 'ecookbook'} |
|
275 | 273 | assert_response :success |
|
276 | 274 | |
|
277 |
assert_include visible, |
|
|
278 |
assert_not_include hidden, |
|
|
275 | assert_include visible.name, response.body | |
|
276 | assert_not_include hidden.name, response.body | |
|
279 | 277 | end |
|
280 | 278 | |
|
281 | 279 | def test_append |
@@ -28,33 +28,32 class WelcomeControllerTest < Redmine::ControllerTest | |||
|
28 | 28 | def test_index |
|
29 | 29 | get :index |
|
30 | 30 | assert_response :success |
|
31 | assert_template 'index' | |
|
32 | assert_not_nil assigns(:news) | |
|
31 | assert_select 'h3', :text => 'Latest news' | |
|
33 | 32 | end |
|
34 | 33 | |
|
35 | 34 | def test_browser_language |
|
36 | 35 | @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' |
|
37 | 36 | get :index |
|
38 | assert_equal :fr, @controller.current_language | |
|
37 | assert_select 'html[lang=fr]' | |
|
39 | 38 | end |
|
40 | 39 | |
|
41 | 40 | def test_browser_language_alternate |
|
42 | 41 | @request.env['HTTP_ACCEPT_LANGUAGE'] = 'zh-TW' |
|
43 | 42 | get :index |
|
44 | assert_equal :"zh-TW", @controller.current_language | |
|
43 | assert_select 'html[lang=zh-TW]' | |
|
45 | 44 | end |
|
46 | 45 | |
|
47 | 46 | def test_browser_language_alternate_not_valid |
|
48 | 47 | @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr-CA' |
|
49 | 48 | get :index |
|
50 | assert_equal :fr, @controller.current_language | |
|
49 | assert_select 'html[lang=fr]' | |
|
51 | 50 | end |
|
52 | 51 | |
|
53 | 52 | def test_browser_language_should_be_ignored_with_force_default_language_for_anonymous |
|
54 | 53 | @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' |
|
55 | 54 | with_settings :force_default_language_for_anonymous => '1' do |
|
56 | 55 | get :index |
|
57 | assert_equal :en, @controller.current_language | |
|
56 | assert_select 'html[lang=en]' | |
|
58 | 57 | end |
|
59 | 58 | end |
|
60 | 59 | |
@@ -64,7 +63,7 class WelcomeControllerTest < Redmine::ControllerTest | |||
|
64 | 63 | @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' |
|
65 | 64 | with_settings :default_language => 'fi' do |
|
66 | 65 | get :index |
|
67 | assert_equal :it, @controller.current_language | |
|
66 | assert_select 'html[lang=it]' | |
|
68 | 67 | end |
|
69 | 68 | end |
|
70 | 69 | |
@@ -74,7 +73,7 class WelcomeControllerTest < Redmine::ControllerTest | |||
|
74 | 73 | @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' |
|
75 | 74 | with_settings :force_default_language_for_loggedin => '1', :default_language => 'fi' do |
|
76 | 75 | get :index |
|
77 | assert_equal :fi, @controller.current_language | |
|
76 | assert_select 'html[lang=fi]' | |
|
78 | 77 | end |
|
79 | 78 | end |
|
80 | 79 |
@@ -30,9 +30,8 class WikiControllerTest < Redmine::ControllerTest | |||
|
30 | 30 | def test_show_start_page |
|
31 | 31 | get :show, :params => {:project_id => 'ecookbook'} |
|
32 | 32 | assert_response :success |
|
33 | assert_template 'show' | |
|
34 | assert_select 'h1', :text => /CookBook documentation/ | |
|
35 | 33 | |
|
34 | assert_select 'h1', :text => /CookBook documentation/ | |
|
36 | 35 | # child_pages macro |
|
37 | 36 | assert_select 'ul.pages-hierarchy>li>a[href=?]', '/projects/ecookbook/wiki/Page_with_an_inline_image', |
|
38 | 37 | :text => 'Page with an inline image' |
@@ -48,7 +47,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
48 | 47 | def test_show_page_with_name |
|
49 | 48 | get :show, :params => {:project_id => 1, :id => 'Another_page'} |
|
50 | 49 | assert_response :success |
|
51 | assert_template 'show' | |
|
50 | ||
|
52 | 51 | assert_select 'h1', :text => /Another page/ |
|
53 | 52 | # Included page with an inline image |
|
54 | 53 | assert_select 'p', :text => /This is an inline image/ |
@@ -60,7 +59,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
60 | 59 | get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2'} |
|
61 | 60 | end |
|
62 | 61 | assert_response :success |
|
63 | assert_template 'show' | |
|
64 | 62 | |
|
65 | 63 | assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/1', :text => /Previous/ |
|
66 | 64 | assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation/2/diff', :text => /diff/ |
@@ -76,9 +74,8 class WikiControllerTest < Redmine::ControllerTest | |||
|
76 | 74 | content.save! |
|
77 | 75 | |
|
78 | 76 | get :show, :params => {:project_id => 'ecookbook', :id => page.title, :version => '1'} |
|
79 | assert_kind_of WikiContent::Version, assigns(:content) | |
|
80 | 77 | assert_response :success |
|
81 | assert_template 'show' | |
|
78 | assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_an_inline_image', :text => /Current version/ | |
|
82 | 79 | end |
|
83 | 80 | |
|
84 | 81 | def test_show_old_version_without_permission_should_be_denied |
@@ -93,7 +90,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
93 | 90 | get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '1'} |
|
94 | 91 | end |
|
95 | 92 | assert_response :success |
|
96 | assert_template 'show' | |
|
97 | 93 | |
|
98 | 94 | assert_select 'a', :text => /Previous/, :count => 0 |
|
99 | 95 | assert_select 'a', :text => /diff/, :count => 0 |
@@ -150,7 +146,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
150 | 146 | @request.session[:user_id] = 2 |
|
151 | 147 | get :show, :params => {:project_id => 1, :id => 'Unexistent page'} |
|
152 | 148 | assert_response :success |
|
153 | assert_template 'edit' | |
|
149 | assert_select 'textarea[name=?]', 'content[text]' | |
|
154 | 150 | end |
|
155 | 151 | |
|
156 | 152 | def test_show_specific_version_of_an_unexistent_page_without_edit_right |
@@ -162,7 +158,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
162 | 158 | @request.session[:user_id] = 2 |
|
163 | 159 | get :show, :params => {:project_id => 1, :id => 'Unexistent page', :parent => 'Another_page'} |
|
164 | 160 | assert_response :success |
|
165 | assert_template 'edit' | |
|
166 | 161 | assert_select 'select[name=?] option[value="2"][selected=selected]', 'wiki_page[parent_id]' |
|
167 | 162 | end |
|
168 | 163 | |
@@ -179,7 +174,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
179 | 174 | |
|
180 | 175 | get :show, :params => {:project_id => 1, :id => 'NoContent'} |
|
181 | 176 | assert_response :success |
|
182 | assert_template 'edit' | |
|
183 | 177 | assert_select 'textarea[name=?]', 'content[text]' |
|
184 | 178 | end |
|
185 | 179 | |
@@ -188,7 +182,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
188 | 182 | |
|
189 | 183 | get :new, :params => {:project_id => 'ecookbook'} |
|
190 | 184 | assert_response :success |
|
191 | assert_template 'new' | |
|
185 | assert_select 'input[name=?]', 'title' | |
|
192 | 186 | end |
|
193 | 187 | |
|
194 | 188 | def test_get_new_xhr |
@@ -196,7 +190,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
196 | 190 | |
|
197 | 191 | xhr :get, :new, :params => {:project_id => 'ecookbook'} |
|
198 | 192 | assert_response :success |
|
199 | assert_template 'new' | |
|
193 | assert_include 'Unallowed characters', response.body | |
|
200 | 194 | end |
|
201 | 195 | |
|
202 | 196 | def test_post_new_with_valid_title_should_redirect_to_edit |
@@ -219,7 +213,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
219 | 213 | |
|
220 | 214 | post :new, :params => {:project_id => 'ecookbook', :title => 'Another page'} |
|
221 | 215 | assert_response :success |
|
222 | assert_template 'new' | |
|
223 | 216 | assert_select_error 'Title has already been taken' |
|
224 | 217 | end |
|
225 | 218 | |
@@ -228,7 +221,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
228 | 221 | |
|
229 | 222 | xhr :post, :new, :params => {:project_id => 'ecookbook', :title => 'Another page'} |
|
230 | 223 | assert_response :success |
|
231 | assert_template 'new' | |
|
232 | 224 | assert_include 'Title has already been taken', response.body |
|
233 | 225 | end |
|
234 | 226 | |
@@ -298,7 +290,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
298 | 290 | get :edit, :params => {:project_id => 'ecookbook', :id => 'Another_page'} |
|
299 | 291 | |
|
300 | 292 | assert_response :success |
|
301 | assert_template 'edit' | |
|
302 | 293 | |
|
303 | 294 | assert_select 'textarea[name=?]', 'content[text]', |
|
304 | 295 | :text => WikiPage.find_by_title('Another_page').content.text |
@@ -309,7 +300,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
309 | 300 | get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 2} |
|
310 | 301 | |
|
311 | 302 | assert_response :success |
|
312 | assert_template 'edit' | |
|
313 | 303 | |
|
314 | 304 | page = WikiPage.find_by_title('Page_with_sections') |
|
315 | 305 | section, hash = Redmine::WikiFormatting::Textile::Formatter.new(page.content.text).get_section(2) |
@@ -398,7 +388,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
398 | 388 | end |
|
399 | 389 | end |
|
400 | 390 | assert_response :success |
|
401 | assert_template 'edit' | |
|
402 | 391 | |
|
403 | 392 | assert_select_error /Comment is too long/ |
|
404 | 393 | assert_select 'textarea#content_text', :text => "edited" |
@@ -475,7 +464,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
475 | 464 | end |
|
476 | 465 | end |
|
477 | 466 | assert_response :success |
|
478 | assert_template 'edit' | |
|
479 | 467 | assert_select 'div.error', :text => /Data has been updated by another user/ |
|
480 | 468 | assert_select 'textarea[name=?]', 'content[text]', :text => /Text should not be lost/ |
|
481 | 469 | assert_select 'input[name=?][value=?]', 'content[comments]', 'My comments' |
@@ -577,7 +565,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
577 | 565 | end |
|
578 | 566 | end |
|
579 | 567 | assert_response :success |
|
580 | assert_template 'edit' | |
|
581 | 568 | assert_select 'div.error', :text => /Data has been updated by another user/ |
|
582 | 569 | assert_select 'textarea[name=?]', 'content[text]', :text => /Text should not be lost/ |
|
583 | 570 | assert_select 'input[name=?][value=?]', 'content[comments]', 'My comments' |
@@ -595,7 +582,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
595 | 582 | } |
|
596 | 583 | } |
|
597 | 584 | assert_response :success |
|
598 | assert_template 'common/_preview' | |
|
599 | 585 | assert_select 'strong', :text => /previewed text/ |
|
600 | 586 | end |
|
601 | 587 | |
@@ -611,7 +597,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
611 | 597 | } |
|
612 | 598 | } |
|
613 | 599 | assert_response :success |
|
614 | assert_template 'common/_preview' | |
|
615 | 600 | assert_select 'h1', :text => /New page/ |
|
616 | 601 | end |
|
617 | 602 | |
@@ -619,9 +604,10 class WikiControllerTest < Redmine::ControllerTest | |||
|
619 | 604 | @request.session[:user_id] = 2 |
|
620 | 605 | get :history, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation'} |
|
621 | 606 | assert_response :success |
|
622 | assert_template 'history' | |
|
623 | assert_not_nil assigns(:versions) | |
|
624 | assert_equal 3, assigns(:versions).size | |
|
607 | ||
|
608 | assert_select 'table.wiki-page-versions tbody' do | |
|
609 | assert_select 'tr', 3 | |
|
610 | end | |
|
625 | 611 | |
|
626 | 612 | assert_select "input[type=submit][name=commit]" |
|
627 | 613 | assert_select 'td' do |
@@ -635,9 +621,11 class WikiControllerTest < Redmine::ControllerTest | |||
|
635 | 621 | @request.session[:user_id] = 2 |
|
636 | 622 | get :history, :params => {:project_id => 'ecookbook', :id => 'Another_page'} |
|
637 | 623 | assert_response :success |
|
638 | assert_template 'history' | |
|
639 | assert_not_nil assigns(:versions) | |
|
640 | assert_equal 1, assigns(:versions).size | |
|
624 | ||
|
625 | assert_select 'table.wiki-page-versions tbody' do | |
|
626 | assert_select 'tr', 1 | |
|
627 | end | |
|
628 | ||
|
641 | 629 | assert_select "input[type=submit][name=commit]", false |
|
642 | 630 | assert_select 'td' do |
|
643 | 631 | assert_select 'a[href=?]', '/projects/ecookbook/wiki/Another_page/1', :text => '1' |
@@ -661,7 +649,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
661 | 649 | :version_from => (content.version - 1) |
|
662 | 650 | } |
|
663 | 651 | assert_response :success |
|
664 | assert_template 'diff' | |
|
665 | 652 | assert_select 'span.diff_out', :text => 'Line removed' |
|
666 | 653 | assert_select 'span.diff_in', :text => 'Line added' |
|
667 | 654 | end |
@@ -689,13 +676,19 class WikiControllerTest < Redmine::ControllerTest | |||
|
689 | 676 | :version => 2 |
|
690 | 677 | } |
|
691 | 678 | assert_response :success |
|
692 | assert_template 'annotate' | |
|
693 | 679 | |
|
694 | 680 | # Line 1 |
|
695 | 681 | assert_select 'table.annotate tr:nth-child(1)' do |
|
696 | 682 | assert_select 'th.line-num', :text => '1' |
|
683 | assert_select 'td.author', :text => /Redmine Admin/ | |
|
684 | assert_select 'td', :text => /h1\. CookBook documentation v2/ | |
|
685 | end | |
|
686 | ||
|
687 | # Line 4 | |
|
688 | assert_select 'table.annotate tr:nth-child(4)' do | |
|
689 | assert_select 'th.line-num', :text => '4' | |
|
697 | 690 | assert_select 'td.author', :text => /John Smith/ |
|
698 |
assert_select 'td', :text => / |
|
|
691 | assert_select 'td', :text => /Line from v1/ | |
|
699 | 692 | end |
|
700 | 693 | |
|
701 | 694 | # Line 5 |
@@ -718,7 +711,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
718 | 711 | @request.session[:user_id] = 2 |
|
719 | 712 | get :rename, :params => {:project_id => 1, :id => 'Another_page'} |
|
720 | 713 | assert_response :success |
|
721 | assert_template 'rename' | |
|
722 | 714 | |
|
723 | 715 | assert_select 'select[name=?]', 'wiki_page[parent_id]' do |
|
724 | 716 | assert_select 'option[value=""]', :text => '' |
@@ -730,7 +722,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
730 | 722 | @request.session[:user_id] = 2 |
|
731 | 723 | get :rename, :params => {:project_id => 1, :id => 'Child_1'} |
|
732 | 724 | assert_response :success |
|
733 | assert_template 'rename' | |
|
734 | 725 | |
|
735 | 726 | assert_select 'select[name=?]', 'wiki_page[parent_id]' do |
|
736 | 727 | assert_select 'option[value=""]', :text => '' |
@@ -808,7 +799,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
808 | 799 | |
|
809 | 800 | get :rename, :params => {:project_id => 1, :id => 'Another_page'} |
|
810 | 801 | assert_response :success |
|
811 | assert_template 'rename' | |
|
812 | 802 | |
|
813 | 803 | assert_select 'select[name=?]', 'wiki_page[wiki_id]' do |
|
814 | 804 | assert_select 'option', 2 |
@@ -849,7 +839,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
849 | 839 | delete :destroy, :params => {:project_id => 1, :id => 'Another_page'} |
|
850 | 840 | end |
|
851 | 841 | assert_response :success |
|
852 | assert_template 'destroy' | |
|
853 | 842 | assert_select 'form' do |
|
854 | 843 | assert_select 'input[name=todo][value=nullify]' |
|
855 | 844 | assert_select 'input[name=todo][value=destroy]' |
@@ -913,11 +902,10 class WikiControllerTest < Redmine::ControllerTest | |||
|
913 | 902 | def test_index |
|
914 | 903 | get :index, :params => {:project_id => 'ecookbook'} |
|
915 | 904 | assert_response :success |
|
916 | assert_template 'index' | |
|
917 | pages = assigns(:pages) | |
|
918 | assert_not_nil pages | |
|
919 | assert_equal Project.find(1).wiki.pages.size, pages.size | |
|
920 | assert_equal pages.first.content.updated_on, pages.first.updated_on | |
|
905 | ||
|
906 | assert_select 'ul.pages-hierarchy' do | |
|
907 | assert_select 'li', Project.find(1).wiki.pages.count | |
|
908 | end | |
|
921 | 909 | |
|
922 | 910 | assert_select 'ul.pages-hierarchy' do |
|
923 | 911 | assert_select 'li' do |
@@ -938,8 +926,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
938 | 926 | get :export, :params => {:project_id => 'ecookbook'} |
|
939 | 927 | |
|
940 | 928 | assert_response :success |
|
941 | assert_not_nil assigns(:pages) | |
|
942 | assert assigns(:pages).any? | |
|
943 | 929 | assert_equal "text/html", @response.content_type |
|
944 | 930 | |
|
945 | 931 | assert_select "a[name=?]", "CookBook_documentation" |
@@ -952,8 +938,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
952 | 938 | get :export, :params => {:project_id => 'ecookbook', :format => 'pdf'} |
|
953 | 939 | |
|
954 | 940 | assert_response :success |
|
955 | assert_not_nil assigns(:pages) | |
|
956 | assert assigns(:pages).any? | |
|
957 | 941 | assert_equal 'application/pdf', @response.content_type |
|
958 | 942 | assert_equal 'attachment; filename="ecookbook.pdf"', @response.headers['Content-Disposition'] |
|
959 | 943 | assert @response.body.starts_with?('%PDF') |
@@ -971,9 +955,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
971 | 955 | get :date_index, :params => {:project_id => 'ecookbook'} |
|
972 | 956 | |
|
973 | 957 | assert_response :success |
|
974 | assert_template 'date_index' | |
|
975 | assert_not_nil assigns(:pages) | |
|
976 | assert_not_nil assigns(:pages_by_date) | |
|
977 | 958 | |
|
978 | 959 | assert_select 'a[href=?]', '/projects/ecookbook/activity.atom?show_wiki_edits=1' |
|
979 | 960 | end |
@@ -1005,7 +986,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
1005 | 986 | @request.session[:user_id] = 2 |
|
1006 | 987 | get :show, :params => {:project_id => 1} |
|
1007 | 988 | assert_response :success |
|
1008 | assert_template 'show' | |
|
989 | ||
|
1009 | 990 | assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit' |
|
1010 | 991 | end |
|
1011 | 992 | |
@@ -1013,7 +994,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
1013 | 994 | @request.session[:user_id] = 4 |
|
1014 | 995 | get :show, :params => {:project_id => 1} |
|
1015 | 996 | assert_response :success |
|
1016 | assert_template 'show' | |
|
997 | ||
|
1017 | 998 | assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit', 0 |
|
1018 | 999 | end |
|
1019 | 1000 | |
@@ -1021,7 +1002,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
1021 | 1002 | @request.session[:user_id] = 2 |
|
1022 | 1003 | get :show, :params => {:project_id => 1, :format => 'pdf'} |
|
1023 | 1004 | assert_response :success |
|
1024 | assert_not_nil assigns(:page) | |
|
1005 | ||
|
1025 | 1006 | assert_equal 'application/pdf', @response.content_type |
|
1026 | 1007 | assert_equal 'attachment; filename="CookBook_documentation.pdf"', |
|
1027 | 1008 | @response.headers['Content-Disposition'] |
@@ -1031,7 +1012,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
1031 | 1012 | @request.session[:user_id] = 2 |
|
1032 | 1013 | get :show, :params => {:project_id => 1, :format => 'html'} |
|
1033 | 1014 | assert_response :success |
|
1034 | assert_not_nil assigns(:page) | |
|
1015 | ||
|
1035 | 1016 | assert_equal 'text/html', @response.content_type |
|
1036 | 1017 | assert_equal 'attachment; filename="CookBook_documentation.html"', |
|
1037 | 1018 | @response.headers['Content-Disposition'] |
@@ -1042,19 +1023,18 class WikiControllerTest < Redmine::ControllerTest | |||
|
1042 | 1023 | @request.session[:user_id] = 2 |
|
1043 | 1024 | get :show, :params => {:project_id => 1, :format => 'html', :version => 2} |
|
1044 | 1025 | assert_response :success |
|
1045 | assert_not_nil assigns(:content) | |
|
1046 | assert_equal 2, assigns(:content).version | |
|
1026 | ||
|
1047 | 1027 | assert_equal 'text/html', @response.content_type |
|
1048 | 1028 | assert_equal 'attachment; filename="CookBook_documentation.html"', |
|
1049 | 1029 | @response.headers['Content-Disposition'] |
|
1050 | assert_select 'h1', :text => /CookBook documentation/ | |
|
1030 | assert_select 'h1', :text => /CookBook documentation v2/ | |
|
1051 | 1031 | end |
|
1052 | 1032 | |
|
1053 | 1033 | def test_show_txt |
|
1054 | 1034 | @request.session[:user_id] = 2 |
|
1055 | 1035 | get :show, :params => {:project_id => 1, :format => 'txt'} |
|
1056 | 1036 | assert_response :success |
|
1057 | assert_not_nil assigns(:page) | |
|
1037 | ||
|
1058 | 1038 | assert_equal 'text/plain', @response.content_type |
|
1059 | 1039 | assert_equal 'attachment; filename="CookBook_documentation.txt"', |
|
1060 | 1040 | @response.headers['Content-Disposition'] |
@@ -1065,12 +1045,11 class WikiControllerTest < Redmine::ControllerTest | |||
|
1065 | 1045 | @request.session[:user_id] = 2 |
|
1066 | 1046 | get :show, :params => {:project_id => 1, :format => 'txt', :version => 2} |
|
1067 | 1047 | assert_response :success |
|
1068 | assert_not_nil assigns(:content) | |
|
1069 | assert_equal 2, assigns(:content).version | |
|
1048 | ||
|
1070 | 1049 | assert_equal 'text/plain', @response.content_type |
|
1071 | 1050 | assert_equal 'attachment; filename="CookBook_documentation.txt"', |
|
1072 | 1051 | @response.headers['Content-Disposition'] |
|
1073 | assert_include 'h1. CookBook documentation', @response.body | |
|
1052 | assert_include 'h1. CookBook documentation v2', @response.body | |
|
1074 | 1053 | end |
|
1075 | 1054 | |
|
1076 | 1055 | def test_edit_unprotected_page |
@@ -1078,7 +1057,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
1078 | 1057 | @request.session[:user_id] = 4 |
|
1079 | 1058 | get :edit, :params => {:project_id => 1, :id => 'Another_page'} |
|
1080 | 1059 | assert_response :success |
|
1081 | assert_template 'edit' | |
|
1082 | 1060 | end |
|
1083 | 1061 | |
|
1084 | 1062 | def test_edit_protected_page_by_nonmember |
@@ -1092,7 +1070,6 class WikiControllerTest < Redmine::ControllerTest | |||
|
1092 | 1070 | @request.session[:user_id] = 2 |
|
1093 | 1071 | get :edit, :params => {:project_id => 1, :id => 'CookBook_documentation'} |
|
1094 | 1072 | assert_response :success |
|
1095 | assert_template 'edit' | |
|
1096 | 1073 | end |
|
1097 | 1074 | |
|
1098 | 1075 | def test_history_of_non_existing_page_should_return_404 |
@@ -31,7 +31,6 class WikisControllerTest < Redmine::ControllerTest | |||
|
31 | 31 | assert_difference 'Wiki.count' do |
|
32 | 32 | xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => 'Start page' }} |
|
33 | 33 | assert_response :success |
|
34 | assert_template 'edit' | |
|
35 | 34 | assert_equal 'text/javascript', response.content_type |
|
36 | 35 | end |
|
37 | 36 | |
@@ -46,7 +45,6 class WikisControllerTest < Redmine::ControllerTest | |||
|
46 | 45 | assert_no_difference 'Wiki.count' do |
|
47 | 46 | xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => '' }} |
|
48 | 47 | assert_response :success |
|
49 | assert_template 'edit' | |
|
50 | 48 | assert_equal 'text/javascript', response.content_type |
|
51 | 49 | end |
|
52 | 50 | |
@@ -60,7 +58,6 class WikisControllerTest < Redmine::ControllerTest | |||
|
60 | 58 | assert_no_difference 'Wiki.count' do |
|
61 | 59 | xhr :post, :edit, :params => {:id => 1, :wiki => { :start_page => 'Other start page' }} |
|
62 | 60 | assert_response :success |
|
63 | assert_template 'edit' | |
|
64 | 61 | assert_equal 'text/javascript', response.content_type |
|
65 | 62 | end |
|
66 | 63 |
@@ -28,7 +28,6 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
28 | 28 | def test_index |
|
29 | 29 | get :index |
|
30 | 30 | assert_response :success |
|
31 | assert_template 'index' | |
|
32 | 31 | |
|
33 | 32 | count = WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count |
|
34 | 33 | assert_select 'a[href=?]', '/workflows/edit?role_id=1&tracker_id=2', :content => count.to_s |
@@ -37,7 +36,6 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
37 | 36 | def test_get_edit |
|
38 | 37 | get :edit |
|
39 | 38 | assert_response :success |
|
40 | assert_template 'edit' | |
|
41 | 39 | end |
|
42 | 40 | |
|
43 | 41 | def test_get_edit_with_role_and_tracker |
@@ -47,11 +45,11 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
47 | 45 | |
|
48 | 46 | get :edit, :params => {:role_id => 2, :tracker_id => 1} |
|
49 | 47 | assert_response :success |
|
50 | assert_template 'edit' | |
|
51 | 48 | |
|
52 | 49 | # used status only |
|
53 | assert_not_nil assigns(:statuses) | |
|
54 | assert_equal [2, 3, 5], assigns(:statuses).collect(&:id) | |
|
50 | statuses = IssueStatus.where(:id => [2, 3, 5]).sorted.pluck(:name) | |
|
51 | assert_equal ["New issue"] + statuses, | |
|
52 | css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip) | |
|
55 | 53 | |
|
56 | 54 | # allowed transitions |
|
57 | 55 | assert_select 'input[type=checkbox][name=?][value="1"][checked=checked]', 'transitions[3][5][always]' |
@@ -74,8 +72,13 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
74 | 72 | def test_get_edit_with_all_roles_and_all_trackers |
|
75 | 73 | get :edit, :params => {:role_id => 'all', :tracker_id => 'all'} |
|
76 | 74 | assert_response :success |
|
77 | assert_equal Role.sorted.to_a, assigns(:roles) | |
|
78 | assert_equal Tracker.sorted.to_a, assigns(:trackers) | |
|
75 | ||
|
76 | assert_select 'select[name=?][multiple=multiple]', 'role_id[]' do | |
|
77 | assert_select 'option[selected=selected]', Role.all.select(&:consider_workflow?).count | |
|
78 | end | |
|
79 | assert_select 'select[name=?]', 'tracker_id[]' do | |
|
80 | assert_select 'option[selected=selected][value=all]' | |
|
81 | end | |
|
79 | 82 | end |
|
80 | 83 | |
|
81 | 84 | def test_get_edit_with_role_and_tracker_and_all_statuses |
@@ -83,10 +86,10 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
83 | 86 | |
|
84 | 87 | get :edit, :params => {:role_id => 2, :tracker_id => 1, :used_statuses_only => '0'} |
|
85 | 88 | assert_response :success |
|
86 | assert_template 'edit' | |
|
87 | 89 | |
|
88 | assert_not_nil assigns(:statuses) | |
|
89 | assert_equal IssueStatus.count, assigns(:statuses).size | |
|
90 | statuses = IssueStatus.all.sorted.pluck(:name) | |
|
91 | assert_equal ["New issue"] + statuses, | |
|
92 | css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip) | |
|
90 | 93 | |
|
91 | 94 | assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]' |
|
92 | 95 | end |
@@ -161,7 +164,6 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
161 | 164 | get :permissions |
|
162 | 165 | |
|
163 | 166 | assert_response :success |
|
164 | assert_template 'permissions' | |
|
165 | 167 | end |
|
166 | 168 | |
|
167 | 169 | def test_get_permissions_with_role_and_tracker |
@@ -172,7 +174,6 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
172 | 174 | |
|
173 | 175 | get :permissions, :params => {:role_id => 1, :tracker_id => 2} |
|
174 | 176 | assert_response :success |
|
175 | assert_template 'permissions' | |
|
176 | 177 | |
|
177 | 178 | assert_select 'input[name=?][value="1"]', 'role_id[]' |
|
178 | 179 | assert_select 'input[name=?][value="2"]', 'tracker_id[]' |
@@ -213,7 +214,6 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
213 | 214 | |
|
214 | 215 | get :permissions, :params => {:role_id => 1, :tracker_id => 1} |
|
215 | 216 | assert_response :success |
|
216 | assert_template 'permissions' | |
|
217 | 217 | |
|
218 | 218 | # Custom field that is always required |
|
219 | 219 | # The default option is "(Required)" |
@@ -231,7 +231,6 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
231 | 231 | |
|
232 | 232 | get :permissions, :params => {:role_id => 2, :tracker_id => 1} |
|
233 | 233 | assert_response :success |
|
234 | assert_template 'permissions' | |
|
235 | 234 | |
|
236 | 235 | assert_select 'select[name=?]:not(.disabled)', "permissions[1][#{cf1.id}]" |
|
237 | 236 | assert_select 'select[name=?]:not(.disabled)', "permissions[1][#{cf3.id}]" |
@@ -287,7 +286,10 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
287 | 286 | |
|
288 | 287 | get :permissions, :params => {:role_id => 1, :tracker_id => 2, :used_statuses_only => '0'} |
|
289 | 288 | assert_response :success |
|
290 | assert_equal IssueStatus.sorted.to_a, assigns(:statuses) | |
|
289 | ||
|
290 | statuses = IssueStatus.all.sorted.pluck(:name) | |
|
291 | assert_equal statuses, | |
|
292 | css_select('table.workflows.fields_permissions thead tr:nth-child(2) td:not(:first-child)').map(&:text).map(&:strip) | |
|
291 | 293 | end |
|
292 | 294 | |
|
293 | 295 | def test_get_permissions_should_set_css_class |
@@ -330,7 +332,7 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
330 | 332 | def test_get_copy |
|
331 | 333 | get :copy |
|
332 | 334 | assert_response :success |
|
333 | assert_template 'copy' | |
|
335 | ||
|
334 | 336 | assert_select 'select[name=source_tracker_id]' do |
|
335 | 337 | assert_select 'option[value="1"]', :text => 'Bug' |
|
336 | 338 | end |
General Comments 0
You need to be logged in to leave comments.
Login now