##// END OF EJS Templates
Restored valid test part removed with r7625 (#8371)....
Etienne Massip -
r7507:78a875784620
parent child
Show More
@@ -1,1704 +1,1707
1 1 # Redmine - project management software
2 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.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19 require 'issues_controller'
20 20
21 21 class IssuesControllerTest < ActionController::TestCase
22 22 fixtures :projects,
23 23 :users,
24 24 :roles,
25 25 :members,
26 26 :member_roles,
27 27 :issues,
28 28 :issue_statuses,
29 29 :versions,
30 30 :trackers,
31 31 :projects_trackers,
32 32 :issue_categories,
33 33 :enabled_modules,
34 34 :enumerations,
35 35 :attachments,
36 36 :workflows,
37 37 :custom_fields,
38 38 :custom_values,
39 39 :custom_fields_projects,
40 40 :custom_fields_trackers,
41 41 :time_entries,
42 42 :journals,
43 43 :journal_details,
44 44 :queries
45 45
46 46 def setup
47 47 @controller = IssuesController.new
48 48 @request = ActionController::TestRequest.new
49 49 @response = ActionController::TestResponse.new
50 50 User.current = nil
51 51 end
52 52
53 53 def test_index
54 54 Setting.default_language = 'en'
55 55
56 56 get :index
57 57 assert_response :success
58 58 assert_template 'index'
59 59 assert_not_nil assigns(:issues)
60 60 assert_nil assigns(:project)
61 61 assert_tag :tag => 'a', :content => /Can't print recipes/
62 62 assert_tag :tag => 'a', :content => /Subproject issue/
63 63 # private projects hidden
64 64 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
65 65 assert_no_tag :tag => 'a', :content => /Issue on project 2/
66 66 # project column
67 67 assert_tag :tag => 'th', :content => /Project/
68 68 end
69 69
70 70 def test_index_should_not_list_issues_when_module_disabled
71 71 EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
72 72 get :index
73 73 assert_response :success
74 74 assert_template 'index'
75 75 assert_not_nil assigns(:issues)
76 76 assert_nil assigns(:project)
77 77 assert_no_tag :tag => 'a', :content => /Can't print recipes/
78 78 assert_tag :tag => 'a', :content => /Subproject issue/
79 79 end
80 80
81 81 def test_index_should_list_visible_issues_only
82 82 get :index, :per_page => 100
83 83 assert_response :success
84 84 assert_not_nil assigns(:issues)
85 85 assert_nil assigns(:issues).detect {|issue| !issue.visible?}
86 86 end
87 87
88 88 def test_index_with_project
89 89 Setting.display_subprojects_issues = 0
90 90 get :index, :project_id => 1
91 91 assert_response :success
92 92 assert_template 'index'
93 93 assert_not_nil assigns(:issues)
94 94 assert_tag :tag => 'a', :content => /Can't print recipes/
95 95 assert_no_tag :tag => 'a', :content => /Subproject issue/
96 96 end
97 97
98 98 def test_index_with_project_and_subprojects
99 99 Setting.display_subprojects_issues = 1
100 100 get :index, :project_id => 1
101 101 assert_response :success
102 102 assert_template 'index'
103 103 assert_not_nil assigns(:issues)
104 104 assert_tag :tag => 'a', :content => /Can't print recipes/
105 105 assert_tag :tag => 'a', :content => /Subproject issue/
106 106 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
107 107 end
108 108
109 109 def test_index_with_project_and_subprojects_should_show_private_subprojects
110 110 @request.session[:user_id] = 2
111 111 Setting.display_subprojects_issues = 1
112 112 get :index, :project_id => 1
113 113 assert_response :success
114 114 assert_template 'index'
115 115 assert_not_nil assigns(:issues)
116 116 assert_tag :tag => 'a', :content => /Can't print recipes/
117 117 assert_tag :tag => 'a', :content => /Subproject issue/
118 118 assert_tag :tag => 'a', :content => /Issue of a private subproject/
119 119 end
120 120
121 121 def test_index_with_project_and_default_filter
122 122 get :index, :project_id => 1, :set_filter => 1
123 123 assert_response :success
124 124 assert_template 'index'
125 125 assert_not_nil assigns(:issues)
126 126
127 127 query = assigns(:query)
128 128 assert_not_nil query
129 129 # default filter
130 130 assert_equal({'status_id' => {:operator => 'o', :values => ['']}}, query.filters)
131 131 end
132 132
133 133 def test_index_with_project_and_filter
134 134 get :index, :project_id => 1, :set_filter => 1,
135 135 :f => ['tracker_id'],
136 136 :op => {'tracker_id' => '='},
137 137 :v => {'tracker_id' => ['1']}
138 138 assert_response :success
139 139 assert_template 'index'
140 140 assert_not_nil assigns(:issues)
141 141
142 142 query = assigns(:query)
143 143 assert_not_nil query
144 144 assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters)
145 145 end
146 146
147 147 def test_index_with_short_filters
148 148
149 149 to_test = {
150 150 'status_id' => {
151 151 'o' => { :op => 'o', :values => [''] },
152 152 'c' => { :op => 'c', :values => [''] },
153 153 '7' => { :op => '=', :values => ['7'] },
154 154 '7|3|4' => { :op => '=', :values => ['7', '3', '4'] },
155 155 '=7' => { :op => '=', :values => ['7'] },
156 156 '!3' => { :op => '!', :values => ['3'] },
157 157 '!7|3|4' => { :op => '!', :values => ['7', '3', '4'] }},
158 158 'subject' => {
159 159 'This is a subject' => { :op => '=', :values => ['This is a subject'] },
160 160 'o' => { :op => '=', :values => ['o'] },
161 161 '~This is part of a subject' => { :op => '~', :values => ['This is part of a subject'] },
162 162 '!~This is part of a subject' => { :op => '!~', :values => ['This is part of a subject'] }},
163 'tracker_id' => {
164 '3' => { :op => '=', :values => ['3'] },
165 '=3' => { :op => '=', :values => ['3'] }},
163 166 'start_date' => {
164 167 '2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
165 168 '=2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
166 169 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
167 170 '<=2011-10-12' => { :op => '<=', :values => ['2011-10-12'] },
168 171 '><2011-10-01|2011-10-30' => { :op => '><', :values => ['2011-10-01', '2011-10-30'] },
169 172 '<t+2' => { :op => '<t+', :values => ['2'] },
170 173 '>t+2' => { :op => '>t+', :values => ['2'] },
171 174 't+2' => { :op => 't+', :values => ['2'] },
172 175 't' => { :op => 't', :values => [''] },
173 176 'w' => { :op => 'w', :values => [''] },
174 177 '>t-2' => { :op => '>t-', :values => ['2'] },
175 178 '<t-2' => { :op => '<t-', :values => ['2'] },
176 179 't-2' => { :op => 't-', :values => ['2'] }},
177 180 'created_on' => {
178 181 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
179 182 '<t+2' => { :op => '=', :values => ['<t+2'] },
180 183 '>t+2' => { :op => '=', :values => ['>t+2'] },
181 184 't+2' => { :op => 't', :values => ['+2'] }},
182 185 'cf_1' => {
183 186 'c' => { :op => '=', :values => ['c'] },
184 187 '!c' => { :op => '!', :values => ['c'] },
185 188 '!*' => { :op => '!*', :values => [''] },
186 189 '*' => { :op => '*', :values => [''] }},
187 190 'estimated_hours' => {
188 191 '=13.4' => { :op => '=', :values => ['13.4'] },
189 192 '>=45' => { :op => '>=', :values => ['45'] },
190 193 '<=125' => { :op => '<=', :values => ['125'] },
191 194 '><10.5|20.5' => { :op => '><', :values => ['10.5', '20.5'] },
192 195 '!*' => { :op => '!*', :values => [''] },
193 196 '*' => { :op => '*', :values => [''] }}
194 197 }
195 198
196 199 default_filter = { 'status_id' => {:operator => 'o', :values => [''] }}
197 200
198 201 to_test.each do |field, expression_and_expected|
199 202 expression_and_expected.each do |filter_expression, expected|
200 203
201 204 get :index, :set_filter => 1, field => filter_expression
202 205
203 206 assert_response :success
204 207 assert_template 'index'
205 208 assert_not_nil assigns(:issues)
206 209
207 210 query = assigns(:query)
208 211 assert_not_nil query
209 212 assert query.has_filter?(field)
210 213 assert_equal(default_filter.merge({field => {:operator => expected[:op], :values => expected[:values]}}), query.filters)
211 214 end
212 215 end
213 216
214 217 end
215 218
216 219 def test_index_with_project_and_empty_filters
217 220 get :index, :project_id => 1, :set_filter => 1, :fields => ['']
218 221 assert_response :success
219 222 assert_template 'index'
220 223 assert_not_nil assigns(:issues)
221 224
222 225 query = assigns(:query)
223 226 assert_not_nil query
224 227 # no filter
225 228 assert_equal({}, query.filters)
226 229 end
227 230
228 231 def test_index_with_query
229 232 get :index, :project_id => 1, :query_id => 5
230 233 assert_response :success
231 234 assert_template 'index'
232 235 assert_not_nil assigns(:issues)
233 236 assert_nil assigns(:issue_count_by_group)
234 237 end
235 238
236 239 def test_index_with_query_grouped_by_tracker
237 240 get :index, :project_id => 1, :query_id => 6
238 241 assert_response :success
239 242 assert_template 'index'
240 243 assert_not_nil assigns(:issues)
241 244 assert_not_nil assigns(:issue_count_by_group)
242 245 end
243 246
244 247 def test_index_with_query_grouped_by_list_custom_field
245 248 get :index, :project_id => 1, :query_id => 9
246 249 assert_response :success
247 250 assert_template 'index'
248 251 assert_not_nil assigns(:issues)
249 252 assert_not_nil assigns(:issue_count_by_group)
250 253 end
251 254
252 255 def test_private_query_should_not_be_available_to_other_users
253 256 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
254 257 @request.session[:user_id] = 3
255 258
256 259 get :index, :query_id => q.id
257 260 assert_response 403
258 261 end
259 262
260 263 def test_private_query_should_be_available_to_its_user
261 264 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
262 265 @request.session[:user_id] = 2
263 266
264 267 get :index, :query_id => q.id
265 268 assert_response :success
266 269 end
267 270
268 271 def test_public_query_should_be_available_to_other_users
269 272 q = Query.create!(:name => "private", :user => User.find(2), :is_public => true, :project => nil)
270 273 @request.session[:user_id] = 3
271 274
272 275 get :index, :query_id => q.id
273 276 assert_response :success
274 277 end
275 278
276 279 def test_index_sort_by_field_not_included_in_columns
277 280 Setting.issue_list_default_columns = %w(subject author)
278 281 get :index, :sort => 'tracker'
279 282 end
280 283
281 284 def test_index_csv_with_project
282 285 Setting.default_language = 'en'
283 286
284 287 get :index, :format => 'csv'
285 288 assert_response :success
286 289 assert_not_nil assigns(:issues)
287 290 assert_equal 'text/csv', @response.content_type
288 291 assert @response.body.starts_with?("#,")
289 292
290 293 get :index, :project_id => 1, :format => 'csv'
291 294 assert_response :success
292 295 assert_not_nil assigns(:issues)
293 296 assert_equal 'text/csv', @response.content_type
294 297 end
295 298
296 299 def test_index_pdf
297 300 get :index, :format => 'pdf'
298 301 assert_response :success
299 302 assert_not_nil assigns(:issues)
300 303 assert_equal 'application/pdf', @response.content_type
301 304
302 305 get :index, :project_id => 1, :format => 'pdf'
303 306 assert_response :success
304 307 assert_not_nil assigns(:issues)
305 308 assert_equal 'application/pdf', @response.content_type
306 309
307 310 get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
308 311 assert_response :success
309 312 assert_not_nil assigns(:issues)
310 313 assert_equal 'application/pdf', @response.content_type
311 314 end
312 315
313 316 def test_index_pdf_with_query_grouped_by_list_custom_field
314 317 get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
315 318 assert_response :success
316 319 assert_not_nil assigns(:issues)
317 320 assert_not_nil assigns(:issue_count_by_group)
318 321 assert_equal 'application/pdf', @response.content_type
319 322 end
320 323
321 324 def test_index_sort
322 325 get :index, :sort => 'tracker,id:desc'
323 326 assert_response :success
324 327
325 328 sort_params = @request.session['issues_index_sort']
326 329 assert sort_params.is_a?(String)
327 330 assert_equal 'tracker,id:desc', sort_params
328 331
329 332 issues = assigns(:issues)
330 333 assert_not_nil issues
331 334 assert !issues.empty?
332 335 assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
333 336 end
334 337
335 338 def test_index_with_columns
336 339 columns = ['tracker', 'subject', 'assigned_to']
337 340 get :index, :set_filter => 1, :c => columns
338 341 assert_response :success
339 342
340 343 # query should use specified columns
341 344 query = assigns(:query)
342 345 assert_kind_of Query, query
343 346 assert_equal columns, query.column_names.map(&:to_s)
344 347
345 348 # columns should be stored in session
346 349 assert_kind_of Hash, session[:query]
347 350 assert_kind_of Array, session[:query][:column_names]
348 351 assert_equal columns, session[:query][:column_names].map(&:to_s)
349 352
350 353 # ensure only these columns are kept in the selected columns list
351 354 assert_tag :tag => 'select', :attributes => { :id => 'selected_columns' },
352 355 :children => { :count => 3 }
353 356 assert_no_tag :tag => 'option', :attributes => { :value => 'project' },
354 357 :parent => { :tag => 'select', :attributes => { :id => "selected_columns" } }
355 358 end
356 359
357 360 def test_index_without_project_should_implicitly_add_project_column_to_default_columns
358 361 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
359 362 get :index, :set_filter => 1
360 363
361 364 # query should use specified columns
362 365 query = assigns(:query)
363 366 assert_kind_of Query, query
364 367 assert_equal [:project, :tracker, :subject, :assigned_to], query.columns.map(&:name)
365 368 end
366 369
367 370 def test_index_without_project_and_explicit_default_columns_should_not_add_project_column
368 371 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
369 372 columns = ['tracker', 'subject', 'assigned_to']
370 373 get :index, :set_filter => 1, :c => columns
371 374
372 375 # query should use specified columns
373 376 query = assigns(:query)
374 377 assert_kind_of Query, query
375 378 assert_equal columns.map(&:to_sym), query.columns.map(&:name)
376 379 end
377 380
378 381 def test_index_with_custom_field_column
379 382 columns = %w(tracker subject cf_2)
380 383 get :index, :set_filter => 1, :c => columns
381 384 assert_response :success
382 385
383 386 # query should use specified columns
384 387 query = assigns(:query)
385 388 assert_kind_of Query, query
386 389 assert_equal columns, query.column_names.map(&:to_s)
387 390
388 391 assert_tag :td,
389 392 :attributes => {:class => 'cf_2 string'},
390 393 :ancestor => {:tag => 'table', :attributes => {:class => /issues/}}
391 394 end
392 395
393 396 def test_index_send_html_if_query_is_invalid
394 397 get :index, :f => ['start_date'], :op => {:start_date => '='}
395 398 assert_equal 'text/html', @response.content_type
396 399 assert_template 'index'
397 400 end
398 401
399 402 def test_index_send_nothing_if_query_is_invalid
400 403 get :index, :f => ['start_date'], :op => {:start_date => '='}, :format => 'csv'
401 404 assert_equal 'text/csv', @response.content_type
402 405 assert @response.body.blank?
403 406 end
404 407
405 408 def test_show_by_anonymous
406 409 get :show, :id => 1
407 410 assert_response :success
408 411 assert_template 'show'
409 412 assert_not_nil assigns(:issue)
410 413 assert_equal Issue.find(1), assigns(:issue)
411 414
412 415 # anonymous role is allowed to add a note
413 416 assert_tag :tag => 'form',
414 417 :descendant => { :tag => 'fieldset',
415 418 :child => { :tag => 'legend',
416 419 :content => /Notes/ } }
417 420 end
418 421
419 422 def test_show_by_manager
420 423 @request.session[:user_id] = 2
421 424 get :show, :id => 1
422 425 assert_response :success
423 426
424 427 assert_tag :tag => 'a',
425 428 :content => /Quote/
426 429
427 430 assert_tag :tag => 'form',
428 431 :descendant => { :tag => 'fieldset',
429 432 :child => { :tag => 'legend',
430 433 :content => /Change properties/ } },
431 434 :descendant => { :tag => 'fieldset',
432 435 :child => { :tag => 'legend',
433 436 :content => /Log time/ } },
434 437 :descendant => { :tag => 'fieldset',
435 438 :child => { :tag => 'legend',
436 439 :content => /Notes/ } }
437 440 end
438 441
439 442 def test_update_form_should_not_display_inactive_enumerations
440 443 @request.session[:user_id] = 2
441 444 get :show, :id => 1
442 445 assert_response :success
443 446
444 447 assert ! IssuePriority.find(15).active?
445 448 assert_no_tag :option, :attributes => {:value => '15'},
446 449 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
447 450 end
448 451
449 452 def test_update_form_should_allow_attachment_upload
450 453 @request.session[:user_id] = 2
451 454 get :show, :id => 1
452 455
453 456 assert_tag :tag => 'form',
454 457 :attributes => {:id => 'issue-form', :method => 'post', :enctype => 'multipart/form-data'},
455 458 :descendant => {
456 459 :tag => 'input',
457 460 :attributes => {:type => 'file', :name => 'attachments[1][file]'}
458 461 }
459 462 end
460 463
461 464 def test_show_should_deny_anonymous_access_without_permission
462 465 Role.anonymous.remove_permission!(:view_issues)
463 466 get :show, :id => 1
464 467 assert_response :redirect
465 468 end
466 469
467 470 def test_show_should_deny_anonymous_access_to_private_issue
468 471 Issue.update_all(["is_private = ?", true], "id = 1")
469 472 get :show, :id => 1
470 473 assert_response :redirect
471 474 end
472 475
473 476 def test_show_should_deny_non_member_access_without_permission
474 477 Role.non_member.remove_permission!(:view_issues)
475 478 @request.session[:user_id] = 9
476 479 get :show, :id => 1
477 480 assert_response 403
478 481 end
479 482
480 483 def test_show_should_deny_non_member_access_to_private_issue
481 484 Issue.update_all(["is_private = ?", true], "id = 1")
482 485 @request.session[:user_id] = 9
483 486 get :show, :id => 1
484 487 assert_response 403
485 488 end
486 489
487 490 def test_show_should_deny_member_access_without_permission
488 491 Role.find(1).remove_permission!(:view_issues)
489 492 @request.session[:user_id] = 2
490 493 get :show, :id => 1
491 494 assert_response 403
492 495 end
493 496
494 497 def test_show_should_deny_member_access_to_private_issue_without_permission
495 498 Issue.update_all(["is_private = ?", true], "id = 1")
496 499 @request.session[:user_id] = 3
497 500 get :show, :id => 1
498 501 assert_response 403
499 502 end
500 503
501 504 def test_show_should_allow_author_access_to_private_issue
502 505 Issue.update_all(["is_private = ?, author_id = 3", true], "id = 1")
503 506 @request.session[:user_id] = 3
504 507 get :show, :id => 1
505 508 assert_response :success
506 509 end
507 510
508 511 def test_show_should_allow_assignee_access_to_private_issue
509 512 Issue.update_all(["is_private = ?, assigned_to_id = 3", true], "id = 1")
510 513 @request.session[:user_id] = 3
511 514 get :show, :id => 1
512 515 assert_response :success
513 516 end
514 517
515 518 def test_show_should_allow_member_access_to_private_issue_with_permission
516 519 Issue.update_all(["is_private = ?", true], "id = 1")
517 520 User.find(3).roles_for_project(Project.find(1)).first.update_attribute :issues_visibility, 'all'
518 521 @request.session[:user_id] = 3
519 522 get :show, :id => 1
520 523 assert_response :success
521 524 end
522 525
523 526 def test_show_should_not_disclose_relations_to_invisible_issues
524 527 Setting.cross_project_issue_relations = '1'
525 528 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
526 529 # Relation to a private project issue
527 530 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
528 531
529 532 get :show, :id => 1
530 533 assert_response :success
531 534
532 535 assert_tag :div, :attributes => { :id => 'relations' },
533 536 :descendant => { :tag => 'a', :content => /#2$/ }
534 537 assert_no_tag :div, :attributes => { :id => 'relations' },
535 538 :descendant => { :tag => 'a', :content => /#4$/ }
536 539 end
537 540
538 541 def test_show_atom
539 542 get :show, :id => 2, :format => 'atom'
540 543 assert_response :success
541 544 assert_template 'journals/index'
542 545 # Inline image
543 546 assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
544 547 end
545 548
546 549 def test_show_export_to_pdf
547 550 get :show, :id => 3, :format => 'pdf'
548 551 assert_response :success
549 552 assert_equal 'application/pdf', @response.content_type
550 553 assert @response.body.starts_with?('%PDF')
551 554 assert_not_nil assigns(:issue)
552 555 end
553 556
554 557 def test_get_new
555 558 @request.session[:user_id] = 2
556 559 get :new, :project_id => 1, :tracker_id => 1
557 560 assert_response :success
558 561 assert_template 'new'
559 562
560 563 assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
561 564 :value => 'Default string' }
562 565
563 566 # Be sure we don't display inactive IssuePriorities
564 567 assert ! IssuePriority.find(15).active?
565 568 assert_no_tag :option, :attributes => {:value => '15'},
566 569 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
567 570 end
568 571
569 572 def test_get_new_form_should_allow_attachment_upload
570 573 @request.session[:user_id] = 2
571 574 get :new, :project_id => 1, :tracker_id => 1
572 575
573 576 assert_tag :tag => 'form',
574 577 :attributes => {:id => 'issue-form', :method => 'post', :enctype => 'multipart/form-data'},
575 578 :descendant => {
576 579 :tag => 'input',
577 580 :attributes => {:type => 'file', :name => 'attachments[1][file]'}
578 581 }
579 582 end
580 583
581 584 def test_get_new_without_tracker_id
582 585 @request.session[:user_id] = 2
583 586 get :new, :project_id => 1
584 587 assert_response :success
585 588 assert_template 'new'
586 589
587 590 issue = assigns(:issue)
588 591 assert_not_nil issue
589 592 assert_equal Project.find(1).trackers.first, issue.tracker
590 593 end
591 594
592 595 def test_get_new_with_no_default_status_should_display_an_error
593 596 @request.session[:user_id] = 2
594 597 IssueStatus.delete_all
595 598
596 599 get :new, :project_id => 1
597 600 assert_response 500
598 601 assert_error_tag :content => /No default issue/
599 602 end
600 603
601 604 def test_get_new_with_no_tracker_should_display_an_error
602 605 @request.session[:user_id] = 2
603 606 Tracker.delete_all
604 607
605 608 get :new, :project_id => 1
606 609 assert_response 500
607 610 assert_error_tag :content => /No tracker/
608 611 end
609 612
610 613 def test_update_new_form
611 614 @request.session[:user_id] = 2
612 615 xhr :post, :new, :project_id => 1,
613 616 :issue => {:tracker_id => 2,
614 617 :subject => 'This is the test_new issue',
615 618 :description => 'This is the description',
616 619 :priority_id => 5}
617 620 assert_response :success
618 621 assert_template 'attributes'
619 622
620 623 issue = assigns(:issue)
621 624 assert_kind_of Issue, issue
622 625 assert_equal 1, issue.project_id
623 626 assert_equal 2, issue.tracker_id
624 627 assert_equal 'This is the test_new issue', issue.subject
625 628 end
626 629
627 630 def test_post_create
628 631 @request.session[:user_id] = 2
629 632 assert_difference 'Issue.count' do
630 633 post :create, :project_id => 1,
631 634 :issue => {:tracker_id => 3,
632 635 :status_id => 2,
633 636 :subject => 'This is the test_new issue',
634 637 :description => 'This is the description',
635 638 :priority_id => 5,
636 639 :start_date => '2010-11-07',
637 640 :estimated_hours => '',
638 641 :custom_field_values => {'2' => 'Value for field 2'}}
639 642 end
640 643 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
641 644
642 645 issue = Issue.find_by_subject('This is the test_new issue')
643 646 assert_not_nil issue
644 647 assert_equal 2, issue.author_id
645 648 assert_equal 3, issue.tracker_id
646 649 assert_equal 2, issue.status_id
647 650 assert_equal Date.parse('2010-11-07'), issue.start_date
648 651 assert_nil issue.estimated_hours
649 652 v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
650 653 assert_not_nil v
651 654 assert_equal 'Value for field 2', v.value
652 655 end
653 656
654 657 def test_post_new_with_group_assignment
655 658 group = Group.find(11)
656 659 project = Project.find(1)
657 660 project.members << Member.new(:principal => group, :roles => [Role.first])
658 661
659 662 with_settings :issue_group_assignment => '1' do
660 663 @request.session[:user_id] = 2
661 664 assert_difference 'Issue.count' do
662 665 post :create, :project_id => project.id,
663 666 :issue => {:tracker_id => 3,
664 667 :status_id => 1,
665 668 :subject => 'This is the test_new_with_group_assignment issue',
666 669 :assigned_to_id => group.id}
667 670 end
668 671 end
669 672 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
670 673
671 674 issue = Issue.find_by_subject('This is the test_new_with_group_assignment issue')
672 675 assert_not_nil issue
673 676 assert_equal group, issue.assigned_to
674 677 end
675 678
676 679 def test_post_create_without_start_date
677 680 @request.session[:user_id] = 2
678 681 assert_difference 'Issue.count' do
679 682 post :create, :project_id => 1,
680 683 :issue => {:tracker_id => 3,
681 684 :status_id => 2,
682 685 :subject => 'This is the test_new issue',
683 686 :description => 'This is the description',
684 687 :priority_id => 5,
685 688 :start_date => '',
686 689 :estimated_hours => '',
687 690 :custom_field_values => {'2' => 'Value for field 2'}}
688 691 end
689 692 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
690 693
691 694 issue = Issue.find_by_subject('This is the test_new issue')
692 695 assert_not_nil issue
693 696 assert_nil issue.start_date
694 697 end
695 698
696 699 def test_post_create_and_continue
697 700 @request.session[:user_id] = 2
698 701 assert_difference 'Issue.count' do
699 702 post :create, :project_id => 1,
700 703 :issue => {:tracker_id => 3, :subject => 'This is first issue', :priority_id => 5},
701 704 :continue => ''
702 705 end
703 706
704 707 issue = Issue.first(:order => 'id DESC')
705 708 assert_redirected_to :controller => 'issues', :action => 'new', :project_id => 'ecookbook', :issue => {:tracker_id => 3}
706 709 assert_not_nil flash[:notice], "flash was not set"
707 710 assert flash[:notice].include?("<a href='/issues/#{issue.id}'>##{issue.id}</a>"), "issue link not found in flash: #{flash[:notice]}"
708 711 end
709 712
710 713 def test_post_create_without_custom_fields_param
711 714 @request.session[:user_id] = 2
712 715 assert_difference 'Issue.count' do
713 716 post :create, :project_id => 1,
714 717 :issue => {:tracker_id => 1,
715 718 :subject => 'This is the test_new issue',
716 719 :description => 'This is the description',
717 720 :priority_id => 5}
718 721 end
719 722 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
720 723 end
721 724
722 725 def test_post_create_with_required_custom_field_and_without_custom_fields_param
723 726 field = IssueCustomField.find_by_name('Database')
724 727 field.update_attribute(:is_required, true)
725 728
726 729 @request.session[:user_id] = 2
727 730 post :create, :project_id => 1,
728 731 :issue => {:tracker_id => 1,
729 732 :subject => 'This is the test_new issue',
730 733 :description => 'This is the description',
731 734 :priority_id => 5}
732 735 assert_response :success
733 736 assert_template 'new'
734 737 issue = assigns(:issue)
735 738 assert_not_nil issue
736 739 assert_equal I18n.translate('activerecord.errors.messages.invalid'), issue.errors.on(:custom_values)
737 740 end
738 741
739 742 def test_post_create_with_watchers
740 743 @request.session[:user_id] = 2
741 744 ActionMailer::Base.deliveries.clear
742 745
743 746 assert_difference 'Watcher.count', 2 do
744 747 post :create, :project_id => 1,
745 748 :issue => {:tracker_id => 1,
746 749 :subject => 'This is a new issue with watchers',
747 750 :description => 'This is the description',
748 751 :priority_id => 5,
749 752 :watcher_user_ids => ['2', '3']}
750 753 end
751 754 issue = Issue.find_by_subject('This is a new issue with watchers')
752 755 assert_not_nil issue
753 756 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
754 757
755 758 # Watchers added
756 759 assert_equal [2, 3], issue.watcher_user_ids.sort
757 760 assert issue.watched_by?(User.find(3))
758 761 # Watchers notified
759 762 mail = ActionMailer::Base.deliveries.last
760 763 assert_kind_of TMail::Mail, mail
761 764 assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
762 765 end
763 766
764 767 def test_post_create_subissue
765 768 @request.session[:user_id] = 2
766 769
767 770 assert_difference 'Issue.count' do
768 771 post :create, :project_id => 1,
769 772 :issue => {:tracker_id => 1,
770 773 :subject => 'This is a child issue',
771 774 :parent_issue_id => 2}
772 775 end
773 776 issue = Issue.find_by_subject('This is a child issue')
774 777 assert_not_nil issue
775 778 assert_equal Issue.find(2), issue.parent
776 779 end
777 780
778 781 def test_post_create_subissue_with_non_numeric_parent_id
779 782 @request.session[:user_id] = 2
780 783
781 784 assert_difference 'Issue.count' do
782 785 post :create, :project_id => 1,
783 786 :issue => {:tracker_id => 1,
784 787 :subject => 'This is a child issue',
785 788 :parent_issue_id => 'ABC'}
786 789 end
787 790 issue = Issue.find_by_subject('This is a child issue')
788 791 assert_not_nil issue
789 792 assert_nil issue.parent
790 793 end
791 794
792 795 def test_post_create_private
793 796 @request.session[:user_id] = 2
794 797
795 798 assert_difference 'Issue.count' do
796 799 post :create, :project_id => 1,
797 800 :issue => {:tracker_id => 1,
798 801 :subject => 'This is a private issue',
799 802 :is_private => '1'}
800 803 end
801 804 issue = Issue.first(:order => 'id DESC')
802 805 assert issue.is_private?
803 806 end
804 807
805 808 def test_post_create_private_with_set_own_issues_private_permission
806 809 role = Role.find(1)
807 810 role.remove_permission! :set_issues_private
808 811 role.add_permission! :set_own_issues_private
809 812
810 813 @request.session[:user_id] = 2
811 814
812 815 assert_difference 'Issue.count' do
813 816 post :create, :project_id => 1,
814 817 :issue => {:tracker_id => 1,
815 818 :subject => 'This is a private issue',
816 819 :is_private => '1'}
817 820 end
818 821 issue = Issue.first(:order => 'id DESC')
819 822 assert issue.is_private?
820 823 end
821 824
822 825 def test_post_create_should_send_a_notification
823 826 ActionMailer::Base.deliveries.clear
824 827 @request.session[:user_id] = 2
825 828 assert_difference 'Issue.count' do
826 829 post :create, :project_id => 1,
827 830 :issue => {:tracker_id => 3,
828 831 :subject => 'This is the test_new issue',
829 832 :description => 'This is the description',
830 833 :priority_id => 5,
831 834 :estimated_hours => '',
832 835 :custom_field_values => {'2' => 'Value for field 2'}}
833 836 end
834 837 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
835 838
836 839 assert_equal 1, ActionMailer::Base.deliveries.size
837 840 end
838 841
839 842 def test_post_create_should_preserve_fields_values_on_validation_failure
840 843 @request.session[:user_id] = 2
841 844 post :create, :project_id => 1,
842 845 :issue => {:tracker_id => 1,
843 846 # empty subject
844 847 :subject => '',
845 848 :description => 'This is a description',
846 849 :priority_id => 6,
847 850 :custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
848 851 assert_response :success
849 852 assert_template 'new'
850 853
851 854 assert_tag :textarea, :attributes => { :name => 'issue[description]' },
852 855 :content => 'This is a description'
853 856 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
854 857 :child => { :tag => 'option', :attributes => { :selected => 'selected',
855 858 :value => '6' },
856 859 :content => 'High' }
857 860 # Custom fields
858 861 assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
859 862 :child => { :tag => 'option', :attributes => { :selected => 'selected',
860 863 :value => 'Oracle' },
861 864 :content => 'Oracle' }
862 865 assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
863 866 :value => 'Value for field 2'}
864 867 end
865 868
866 869 def test_post_create_should_ignore_non_safe_attributes
867 870 @request.session[:user_id] = 2
868 871 assert_nothing_raised do
869 872 post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
870 873 end
871 874 end
872 875
873 876 def test_post_create_with_attachment
874 877 set_tmp_attachments_directory
875 878 @request.session[:user_id] = 2
876 879
877 880 assert_difference 'Issue.count' do
878 881 assert_difference 'Attachment.count' do
879 882 post :create, :project_id => 1,
880 883 :issue => { :tracker_id => '1', :subject => 'With attachment' },
881 884 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
882 885 end
883 886 end
884 887
885 888 issue = Issue.first(:order => 'id DESC')
886 889 attachment = Attachment.first(:order => 'id DESC')
887 890
888 891 assert_equal issue, attachment.container
889 892 assert_equal 2, attachment.author_id
890 893 assert_equal 'testfile.txt', attachment.filename
891 894 assert_equal 'text/plain', attachment.content_type
892 895 assert_equal 'test file', attachment.description
893 896 assert_equal 59, attachment.filesize
894 897 assert File.exists?(attachment.diskfile)
895 898 assert_equal 59, File.size(attachment.diskfile)
896 899 end
897 900
898 901 context "without workflow privilege" do
899 902 setup do
900 903 Workflow.delete_all(["role_id = ?", Role.anonymous.id])
901 904 Role.anonymous.add_permission! :add_issues, :add_issue_notes
902 905 end
903 906
904 907 context "#new" do
905 908 should "propose default status only" do
906 909 get :new, :project_id => 1
907 910 assert_response :success
908 911 assert_template 'new'
909 912 assert_tag :tag => 'select',
910 913 :attributes => {:name => 'issue[status_id]'},
911 914 :children => {:count => 1},
912 915 :child => {:tag => 'option', :attributes => {:value => IssueStatus.default.id.to_s}}
913 916 end
914 917
915 918 should "accept default status" do
916 919 assert_difference 'Issue.count' do
917 920 post :create, :project_id => 1,
918 921 :issue => {:tracker_id => 1,
919 922 :subject => 'This is an issue',
920 923 :status_id => 1}
921 924 end
922 925 issue = Issue.last(:order => 'id')
923 926 assert_equal IssueStatus.default, issue.status
924 927 end
925 928
926 929 should "ignore unauthorized status" do
927 930 assert_difference 'Issue.count' do
928 931 post :create, :project_id => 1,
929 932 :issue => {:tracker_id => 1,
930 933 :subject => 'This is an issue',
931 934 :status_id => 3}
932 935 end
933 936 issue = Issue.last(:order => 'id')
934 937 assert_equal IssueStatus.default, issue.status
935 938 end
936 939 end
937 940
938 941 context "#update" do
939 942 should "ignore status change" do
940 943 assert_difference 'Journal.count' do
941 944 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
942 945 end
943 946 assert_equal 1, Issue.find(1).status_id
944 947 end
945 948
946 949 should "ignore attributes changes" do
947 950 assert_difference 'Journal.count' do
948 951 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
949 952 end
950 953 issue = Issue.find(1)
951 954 assert_equal "Can't print recipes", issue.subject
952 955 assert_nil issue.assigned_to
953 956 end
954 957 end
955 958 end
956 959
957 960 context "with workflow privilege" do
958 961 setup do
959 962 Workflow.delete_all(["role_id = ?", Role.anonymous.id])
960 963 Workflow.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
961 964 Workflow.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
962 965 Role.anonymous.add_permission! :add_issues, :add_issue_notes
963 966 end
964 967
965 968 context "#update" do
966 969 should "accept authorized status" do
967 970 assert_difference 'Journal.count' do
968 971 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
969 972 end
970 973 assert_equal 3, Issue.find(1).status_id
971 974 end
972 975
973 976 should "ignore unauthorized status" do
974 977 assert_difference 'Journal.count' do
975 978 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
976 979 end
977 980 assert_equal 1, Issue.find(1).status_id
978 981 end
979 982
980 983 should "accept authorized attributes changes" do
981 984 assert_difference 'Journal.count' do
982 985 put :update, :id => 1, :notes => 'just trying', :issue => {:assigned_to_id => 2}
983 986 end
984 987 issue = Issue.find(1)
985 988 assert_equal 2, issue.assigned_to_id
986 989 end
987 990
988 991 should "ignore unauthorized attributes changes" do
989 992 assert_difference 'Journal.count' do
990 993 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed'}
991 994 end
992 995 issue = Issue.find(1)
993 996 assert_equal "Can't print recipes", issue.subject
994 997 end
995 998 end
996 999
997 1000 context "and :edit_issues permission" do
998 1001 setup do
999 1002 Role.anonymous.add_permission! :add_issues, :edit_issues
1000 1003 end
1001 1004
1002 1005 should "accept authorized status" do
1003 1006 assert_difference 'Journal.count' do
1004 1007 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3}
1005 1008 end
1006 1009 assert_equal 3, Issue.find(1).status_id
1007 1010 end
1008 1011
1009 1012 should "ignore unauthorized status" do
1010 1013 assert_difference 'Journal.count' do
1011 1014 put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2}
1012 1015 end
1013 1016 assert_equal 1, Issue.find(1).status_id
1014 1017 end
1015 1018
1016 1019 should "accept authorized attributes changes" do
1017 1020 assert_difference 'Journal.count' do
1018 1021 put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2}
1019 1022 end
1020 1023 issue = Issue.find(1)
1021 1024 assert_equal "changed", issue.subject
1022 1025 assert_equal 2, issue.assigned_to_id
1023 1026 end
1024 1027 end
1025 1028 end
1026 1029
1027 1030 def test_copy_issue
1028 1031 @request.session[:user_id] = 2
1029 1032 get :new, :project_id => 1, :copy_from => 1
1030 1033 assert_template 'new'
1031 1034 assert_not_nil assigns(:issue)
1032 1035 orig = Issue.find(1)
1033 1036 assert_equal orig.subject, assigns(:issue).subject
1034 1037 end
1035 1038
1036 1039 def test_get_edit
1037 1040 @request.session[:user_id] = 2
1038 1041 get :edit, :id => 1
1039 1042 assert_response :success
1040 1043 assert_template 'edit'
1041 1044 assert_not_nil assigns(:issue)
1042 1045 assert_equal Issue.find(1), assigns(:issue)
1043 1046
1044 1047 # Be sure we don't display inactive IssuePriorities
1045 1048 assert ! IssuePriority.find(15).active?
1046 1049 assert_no_tag :option, :attributes => {:value => '15'},
1047 1050 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
1048 1051 end
1049 1052
1050 1053 def test_get_edit_with_params
1051 1054 @request.session[:user_id] = 2
1052 1055 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 },
1053 1056 :time_entry => { :hours => '2.5', :comments => 'test_get_edit_with_params', :activity_id => TimeEntryActivity.first.id }
1054 1057 assert_response :success
1055 1058 assert_template 'edit'
1056 1059
1057 1060 issue = assigns(:issue)
1058 1061 assert_not_nil issue
1059 1062
1060 1063 assert_equal 5, issue.status_id
1061 1064 assert_tag :select, :attributes => { :name => 'issue[status_id]' },
1062 1065 :child => { :tag => 'option',
1063 1066 :content => 'Closed',
1064 1067 :attributes => { :selected => 'selected' } }
1065 1068
1066 1069 assert_equal 7, issue.priority_id
1067 1070 assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
1068 1071 :child => { :tag => 'option',
1069 1072 :content => 'Urgent',
1070 1073 :attributes => { :selected => 'selected' } }
1071 1074
1072 1075 assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => '2.5' }
1073 1076 assert_tag :select, :attributes => { :name => 'time_entry[activity_id]' },
1074 1077 :child => { :tag => 'option',
1075 1078 :attributes => { :selected => 'selected', :value => TimeEntryActivity.first.id } }
1076 1079 assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => 'test_get_edit_with_params' }
1077 1080 end
1078 1081
1079 1082 def test_update_edit_form
1080 1083 @request.session[:user_id] = 2
1081 1084 xhr :post, :new, :project_id => 1,
1082 1085 :id => 1,
1083 1086 :issue => {:tracker_id => 2,
1084 1087 :subject => 'This is the test_new issue',
1085 1088 :description => 'This is the description',
1086 1089 :priority_id => 5}
1087 1090 assert_response :success
1088 1091 assert_template 'attributes'
1089 1092
1090 1093 issue = assigns(:issue)
1091 1094 assert_kind_of Issue, issue
1092 1095 assert_equal 1, issue.id
1093 1096 assert_equal 1, issue.project_id
1094 1097 assert_equal 2, issue.tracker_id
1095 1098 assert_equal 'This is the test_new issue', issue.subject
1096 1099 end
1097 1100
1098 1101 def test_update_using_invalid_http_verbs
1099 1102 @request.session[:user_id] = 2
1100 1103 subject = 'Updated by an invalid http verb'
1101 1104
1102 1105 get :update, :id => 1, :issue => {:subject => subject}
1103 1106 assert_not_equal subject, Issue.find(1).subject
1104 1107
1105 1108 post :update, :id => 1, :issue => {:subject => subject}
1106 1109 assert_not_equal subject, Issue.find(1).subject
1107 1110
1108 1111 delete :update, :id => 1, :issue => {:subject => subject}
1109 1112 assert_not_equal subject, Issue.find(1).subject
1110 1113 end
1111 1114
1112 1115 def test_put_update_without_custom_fields_param
1113 1116 @request.session[:user_id] = 2
1114 1117 ActionMailer::Base.deliveries.clear
1115 1118
1116 1119 issue = Issue.find(1)
1117 1120 assert_equal '125', issue.custom_value_for(2).value
1118 1121 old_subject = issue.subject
1119 1122 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
1120 1123
1121 1124 assert_difference('Journal.count') do
1122 1125 assert_difference('JournalDetail.count', 2) do
1123 1126 put :update, :id => 1, :issue => {:subject => new_subject,
1124 1127 :priority_id => '6',
1125 1128 :category_id => '1' # no change
1126 1129 }
1127 1130 end
1128 1131 end
1129 1132 assert_redirected_to :action => 'show', :id => '1'
1130 1133 issue.reload
1131 1134 assert_equal new_subject, issue.subject
1132 1135 # Make sure custom fields were not cleared
1133 1136 assert_equal '125', issue.custom_value_for(2).value
1134 1137
1135 1138 mail = ActionMailer::Base.deliveries.last
1136 1139 assert_kind_of TMail::Mail, mail
1137 1140 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
1138 1141 assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
1139 1142 end
1140 1143
1141 1144 def test_put_update_with_custom_field_change
1142 1145 @request.session[:user_id] = 2
1143 1146 issue = Issue.find(1)
1144 1147 assert_equal '125', issue.custom_value_for(2).value
1145 1148
1146 1149 assert_difference('Journal.count') do
1147 1150 assert_difference('JournalDetail.count', 3) do
1148 1151 put :update, :id => 1, :issue => {:subject => 'Custom field change',
1149 1152 :priority_id => '6',
1150 1153 :category_id => '1', # no change
1151 1154 :custom_field_values => { '2' => 'New custom value' }
1152 1155 }
1153 1156 end
1154 1157 end
1155 1158 assert_redirected_to :action => 'show', :id => '1'
1156 1159 issue.reload
1157 1160 assert_equal 'New custom value', issue.custom_value_for(2).value
1158 1161
1159 1162 mail = ActionMailer::Base.deliveries.last
1160 1163 assert_kind_of TMail::Mail, mail
1161 1164 assert mail.body.include?("Searchable field changed from 125 to New custom value")
1162 1165 end
1163 1166
1164 1167 def test_put_update_with_status_and_assignee_change
1165 1168 issue = Issue.find(1)
1166 1169 assert_equal 1, issue.status_id
1167 1170 @request.session[:user_id] = 2
1168 1171 assert_difference('TimeEntry.count', 0) do
1169 1172 put :update,
1170 1173 :id => 1,
1171 1174 :issue => { :status_id => 2, :assigned_to_id => 3 },
1172 1175 :notes => 'Assigned to dlopper',
1173 1176 :time_entry => { :hours => '', :comments => '', :activity_id => TimeEntryActivity.first }
1174 1177 end
1175 1178 assert_redirected_to :action => 'show', :id => '1'
1176 1179 issue.reload
1177 1180 assert_equal 2, issue.status_id
1178 1181 j = Journal.find(:first, :order => 'id DESC')
1179 1182 assert_equal 'Assigned to dlopper', j.notes
1180 1183 assert_equal 2, j.details.size
1181 1184
1182 1185 mail = ActionMailer::Base.deliveries.last
1183 1186 assert mail.body.include?("Status changed from New to Assigned")
1184 1187 # subject should contain the new status
1185 1188 assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
1186 1189 end
1187 1190
1188 1191 def test_put_update_with_note_only
1189 1192 notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
1190 1193 # anonymous user
1191 1194 put :update,
1192 1195 :id => 1,
1193 1196 :notes => notes
1194 1197 assert_redirected_to :action => 'show', :id => '1'
1195 1198 j = Journal.find(:first, :order => 'id DESC')
1196 1199 assert_equal notes, j.notes
1197 1200 assert_equal 0, j.details.size
1198 1201 assert_equal User.anonymous, j.user
1199 1202
1200 1203 mail = ActionMailer::Base.deliveries.last
1201 1204 assert mail.body.include?(notes)
1202 1205 end
1203 1206
1204 1207 def test_put_update_with_note_and_spent_time
1205 1208 @request.session[:user_id] = 2
1206 1209 spent_hours_before = Issue.find(1).spent_hours
1207 1210 assert_difference('TimeEntry.count') do
1208 1211 put :update,
1209 1212 :id => 1,
1210 1213 :notes => '2.5 hours added',
1211 1214 :time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id }
1212 1215 end
1213 1216 assert_redirected_to :action => 'show', :id => '1'
1214 1217
1215 1218 issue = Issue.find(1)
1216 1219
1217 1220 j = Journal.find(:first, :order => 'id DESC')
1218 1221 assert_equal '2.5 hours added', j.notes
1219 1222 assert_equal 0, j.details.size
1220 1223
1221 1224 t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time')
1222 1225 assert_not_nil t
1223 1226 assert_equal 2.5, t.hours
1224 1227 assert_equal spent_hours_before + 2.5, issue.spent_hours
1225 1228 end
1226 1229
1227 1230 def test_put_update_with_attachment_only
1228 1231 set_tmp_attachments_directory
1229 1232
1230 1233 # Delete all fixtured journals, a race condition can occur causing the wrong
1231 1234 # journal to get fetched in the next find.
1232 1235 Journal.delete_all
1233 1236
1234 1237 # anonymous user
1235 1238 assert_difference 'Attachment.count' do
1236 1239 put :update, :id => 1,
1237 1240 :notes => '',
1238 1241 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
1239 1242 end
1240 1243
1241 1244 assert_redirected_to :action => 'show', :id => '1'
1242 1245 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
1243 1246 assert j.notes.blank?
1244 1247 assert_equal 1, j.details.size
1245 1248 assert_equal 'testfile.txt', j.details.first.value
1246 1249 assert_equal User.anonymous, j.user
1247 1250
1248 1251 attachment = Attachment.first(:order => 'id DESC')
1249 1252 assert_equal Issue.find(1), attachment.container
1250 1253 assert_equal User.anonymous, attachment.author
1251 1254 assert_equal 'testfile.txt', attachment.filename
1252 1255 assert_equal 'text/plain', attachment.content_type
1253 1256 assert_equal 'test file', attachment.description
1254 1257 assert_equal 59, attachment.filesize
1255 1258 assert File.exists?(attachment.diskfile)
1256 1259 assert_equal 59, File.size(attachment.diskfile)
1257 1260
1258 1261 mail = ActionMailer::Base.deliveries.last
1259 1262 assert mail.body.include?('testfile.txt')
1260 1263 end
1261 1264
1262 1265 def test_put_update_with_attachment_that_fails_to_save
1263 1266 set_tmp_attachments_directory
1264 1267
1265 1268 # Delete all fixtured journals, a race condition can occur causing the wrong
1266 1269 # journal to get fetched in the next find.
1267 1270 Journal.delete_all
1268 1271
1269 1272 # Mock out the unsaved attachment
1270 1273 Attachment.any_instance.stubs(:create).returns(Attachment.new)
1271 1274
1272 1275 # anonymous user
1273 1276 put :update,
1274 1277 :id => 1,
1275 1278 :notes => '',
1276 1279 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
1277 1280 assert_redirected_to :action => 'show', :id => '1'
1278 1281 assert_equal '1 file(s) could not be saved.', flash[:warning]
1279 1282
1280 1283 end if Object.const_defined?(:Mocha)
1281 1284
1282 1285 def test_put_update_with_no_change
1283 1286 issue = Issue.find(1)
1284 1287 issue.journals.clear
1285 1288 ActionMailer::Base.deliveries.clear
1286 1289
1287 1290 put :update,
1288 1291 :id => 1,
1289 1292 :notes => ''
1290 1293 assert_redirected_to :action => 'show', :id => '1'
1291 1294
1292 1295 issue.reload
1293 1296 assert issue.journals.empty?
1294 1297 # No email should be sent
1295 1298 assert ActionMailer::Base.deliveries.empty?
1296 1299 end
1297 1300
1298 1301 def test_put_update_should_send_a_notification
1299 1302 @request.session[:user_id] = 2
1300 1303 ActionMailer::Base.deliveries.clear
1301 1304 issue = Issue.find(1)
1302 1305 old_subject = issue.subject
1303 1306 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
1304 1307
1305 1308 put :update, :id => 1, :issue => {:subject => new_subject,
1306 1309 :priority_id => '6',
1307 1310 :category_id => '1' # no change
1308 1311 }
1309 1312 assert_equal 1, ActionMailer::Base.deliveries.size
1310 1313 end
1311 1314
1312 1315 def test_put_update_with_invalid_spent_time_hours_only
1313 1316 @request.session[:user_id] = 2
1314 1317 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
1315 1318
1316 1319 assert_no_difference('Journal.count') do
1317 1320 put :update,
1318 1321 :id => 1,
1319 1322 :notes => notes,
1320 1323 :time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"}
1321 1324 end
1322 1325 assert_response :success
1323 1326 assert_template 'edit'
1324 1327
1325 1328 assert_error_tag :descendant => {:content => /Activity can't be blank/}
1326 1329 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => notes
1327 1330 assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
1328 1331 end
1329 1332
1330 1333 def test_put_update_with_invalid_spent_time_comments_only
1331 1334 @request.session[:user_id] = 2
1332 1335 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
1333 1336
1334 1337 assert_no_difference('Journal.count') do
1335 1338 put :update,
1336 1339 :id => 1,
1337 1340 :notes => notes,
1338 1341 :time_entry => {"comments"=>"this is my comment", "activity_id"=>"", "hours"=>""}
1339 1342 end
1340 1343 assert_response :success
1341 1344 assert_template 'edit'
1342 1345
1343 1346 assert_error_tag :descendant => {:content => /Activity can't be blank/}
1344 1347 assert_error_tag :descendant => {:content => /Hours can't be blank/}
1345 1348 assert_tag :textarea, :attributes => { :name => 'notes' }, :content => notes
1346 1349 assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => "this is my comment" }
1347 1350 end
1348 1351
1349 1352 def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
1350 1353 issue = Issue.find(2)
1351 1354 @request.session[:user_id] = 2
1352 1355
1353 1356 put :update,
1354 1357 :id => issue.id,
1355 1358 :issue => {
1356 1359 :fixed_version_id => 4
1357 1360 }
1358 1361
1359 1362 assert_response :redirect
1360 1363 issue.reload
1361 1364 assert_equal 4, issue.fixed_version_id
1362 1365 assert_not_equal issue.project_id, issue.fixed_version.project_id
1363 1366 end
1364 1367
1365 1368 def test_put_update_should_redirect_back_using_the_back_url_parameter
1366 1369 issue = Issue.find(2)
1367 1370 @request.session[:user_id] = 2
1368 1371
1369 1372 put :update,
1370 1373 :id => issue.id,
1371 1374 :issue => {
1372 1375 :fixed_version_id => 4
1373 1376 },
1374 1377 :back_url => '/issues'
1375 1378
1376 1379 assert_response :redirect
1377 1380 assert_redirected_to '/issues'
1378 1381 end
1379 1382
1380 1383 def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
1381 1384 issue = Issue.find(2)
1382 1385 @request.session[:user_id] = 2
1383 1386
1384 1387 put :update,
1385 1388 :id => issue.id,
1386 1389 :issue => {
1387 1390 :fixed_version_id => 4
1388 1391 },
1389 1392 :back_url => 'http://google.com'
1390 1393
1391 1394 assert_response :redirect
1392 1395 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
1393 1396 end
1394 1397
1395 1398 def test_get_bulk_edit
1396 1399 @request.session[:user_id] = 2
1397 1400 get :bulk_edit, :ids => [1, 2]
1398 1401 assert_response :success
1399 1402 assert_template 'bulk_edit'
1400 1403
1401 1404 assert_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
1402 1405
1403 1406 # Project specific custom field, date type
1404 1407 field = CustomField.find(9)
1405 1408 assert !field.is_for_all?
1406 1409 assert_equal 'date', field.field_format
1407 1410 assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
1408 1411
1409 1412 # System wide custom field
1410 1413 assert CustomField.find(1).is_for_all?
1411 1414 assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
1412 1415
1413 1416 # Be sure we don't display inactive IssuePriorities
1414 1417 assert ! IssuePriority.find(15).active?
1415 1418 assert_no_tag :option, :attributes => {:value => '15'},
1416 1419 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
1417 1420 end
1418 1421
1419 1422 def test_get_bulk_edit_on_different_projects
1420 1423 @request.session[:user_id] = 2
1421 1424 get :bulk_edit, :ids => [1, 2, 6]
1422 1425 assert_response :success
1423 1426 assert_template 'bulk_edit'
1424 1427
1425 1428 # Can not set issues from different projects as children of an issue
1426 1429 assert_no_tag :input, :attributes => {:name => 'issue[parent_issue_id]'}
1427 1430
1428 1431 # Project specific custom field, date type
1429 1432 field = CustomField.find(9)
1430 1433 assert !field.is_for_all?
1431 1434 assert !field.project_ids.include?(Issue.find(6).project_id)
1432 1435 assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
1433 1436 end
1434 1437
1435 1438 def test_get_bulk_edit_with_user_custom_field
1436 1439 field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true)
1437 1440
1438 1441 @request.session[:user_id] = 2
1439 1442 get :bulk_edit, :ids => [1, 2]
1440 1443 assert_response :success
1441 1444 assert_template 'bulk_edit'
1442 1445
1443 1446 assert_tag :select,
1444 1447 :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
1445 1448 :children => {
1446 1449 :only => {:tag => 'option'},
1447 1450 :count => Project.find(1).users.count + 1
1448 1451 }
1449 1452 end
1450 1453
1451 1454 def test_get_bulk_edit_with_version_custom_field
1452 1455 field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true)
1453 1456
1454 1457 @request.session[:user_id] = 2
1455 1458 get :bulk_edit, :ids => [1, 2]
1456 1459 assert_response :success
1457 1460 assert_template 'bulk_edit'
1458 1461
1459 1462 assert_tag :select,
1460 1463 :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
1461 1464 :children => {
1462 1465 :only => {:tag => 'option'},
1463 1466 :count => Project.find(1).versions.count + 1
1464 1467 }
1465 1468 end
1466 1469
1467 1470 def test_bulk_update
1468 1471 @request.session[:user_id] = 2
1469 1472 # update issues priority
1470 1473 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
1471 1474 :issue => {:priority_id => 7,
1472 1475 :assigned_to_id => '',
1473 1476 :custom_field_values => {'2' => ''}}
1474 1477
1475 1478 assert_response 302
1476 1479 # check that the issues were updated
1477 1480 assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
1478 1481
1479 1482 issue = Issue.find(1)
1480 1483 journal = issue.journals.find(:first, :order => 'created_on DESC')
1481 1484 assert_equal '125', issue.custom_value_for(2).value
1482 1485 assert_equal 'Bulk editing', journal.notes
1483 1486 assert_equal 1, journal.details.size
1484 1487 end
1485 1488
1486 1489 def test_bulk_update_with_group_assignee
1487 1490 group = Group.find(11)
1488 1491 project = Project.find(1)
1489 1492 project.members << Member.new(:principal => group, :roles => [Role.first])
1490 1493
1491 1494 @request.session[:user_id] = 2
1492 1495 # update issues assignee
1493 1496 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
1494 1497 :issue => {:priority_id => '',
1495 1498 :assigned_to_id => group.id,
1496 1499 :custom_field_values => {'2' => ''}}
1497 1500
1498 1501 assert_response 302
1499 1502 assert_equal [group, group], Issue.find_all_by_id([1, 2]).collect {|i| i.assigned_to}
1500 1503 end
1501 1504
1502 1505 def test_bulk_update_on_different_projects
1503 1506 @request.session[:user_id] = 2
1504 1507 # update issues priority
1505 1508 post :bulk_update, :ids => [1, 2, 6], :notes => 'Bulk editing',
1506 1509 :issue => {:priority_id => 7,
1507 1510 :assigned_to_id => '',
1508 1511 :custom_field_values => {'2' => ''}}
1509 1512
1510 1513 assert_response 302
1511 1514 # check that the issues were updated
1512 1515 assert_equal [7, 7, 7], Issue.find([1,2,6]).map(&:priority_id)
1513 1516
1514 1517 issue = Issue.find(1)
1515 1518 journal = issue.journals.find(:first, :order => 'created_on DESC')
1516 1519 assert_equal '125', issue.custom_value_for(2).value
1517 1520 assert_equal 'Bulk editing', journal.notes
1518 1521 assert_equal 1, journal.details.size
1519 1522 end
1520 1523
1521 1524 def test_bulk_update_on_different_projects_without_rights
1522 1525 @request.session[:user_id] = 3
1523 1526 user = User.find(3)
1524 1527 action = { :controller => "issues", :action => "bulk_update" }
1525 1528 assert user.allowed_to?(action, Issue.find(1).project)
1526 1529 assert ! user.allowed_to?(action, Issue.find(6).project)
1527 1530 post :bulk_update, :ids => [1, 6], :notes => 'Bulk should fail',
1528 1531 :issue => {:priority_id => 7,
1529 1532 :assigned_to_id => '',
1530 1533 :custom_field_values => {'2' => ''}}
1531 1534 assert_response 403
1532 1535 assert_not_equal "Bulk should fail", Journal.last.notes
1533 1536 end
1534 1537
1535 1538 def test_bullk_update_should_send_a_notification
1536 1539 @request.session[:user_id] = 2
1537 1540 ActionMailer::Base.deliveries.clear
1538 1541 post(:bulk_update,
1539 1542 {
1540 1543 :ids => [1, 2],
1541 1544 :notes => 'Bulk editing',
1542 1545 :issue => {
1543 1546 :priority_id => 7,
1544 1547 :assigned_to_id => '',
1545 1548 :custom_field_values => {'2' => ''}
1546 1549 }
1547 1550 })
1548 1551
1549 1552 assert_response 302
1550 1553 assert_equal 2, ActionMailer::Base.deliveries.size
1551 1554 end
1552 1555
1553 1556 def test_bulk_update_status
1554 1557 @request.session[:user_id] = 2
1555 1558 # update issues priority
1556 1559 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing status',
1557 1560 :issue => {:priority_id => '',
1558 1561 :assigned_to_id => '',
1559 1562 :status_id => '5'}
1560 1563
1561 1564 assert_response 302
1562 1565 issue = Issue.find(1)
1563 1566 assert issue.closed?
1564 1567 end
1565 1568
1566 1569 def test_bulk_update_parent_id
1567 1570 @request.session[:user_id] = 2
1568 1571 post :bulk_update, :ids => [1, 3],
1569 1572 :notes => 'Bulk editing parent',
1570 1573 :issue => {:priority_id => '', :assigned_to_id => '', :status_id => '', :parent_issue_id => '2'}
1571 1574
1572 1575 assert_response 302
1573 1576 parent = Issue.find(2)
1574 1577 assert_equal parent.id, Issue.find(1).parent_id
1575 1578 assert_equal parent.id, Issue.find(3).parent_id
1576 1579 assert_equal [1, 3], parent.children.collect(&:id).sort
1577 1580 end
1578 1581
1579 1582 def test_bulk_update_custom_field
1580 1583 @request.session[:user_id] = 2
1581 1584 # update issues priority
1582 1585 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing custom field',
1583 1586 :issue => {:priority_id => '',
1584 1587 :assigned_to_id => '',
1585 1588 :custom_field_values => {'2' => '777'}}
1586 1589
1587 1590 assert_response 302
1588 1591
1589 1592 issue = Issue.find(1)
1590 1593 journal = issue.journals.find(:first, :order => 'created_on DESC')
1591 1594 assert_equal '777', issue.custom_value_for(2).value
1592 1595 assert_equal 1, journal.details.size
1593 1596 assert_equal '125', journal.details.first.old_value
1594 1597 assert_equal '777', journal.details.first.value
1595 1598 end
1596 1599
1597 1600 def test_bulk_update_unassign
1598 1601 assert_not_nil Issue.find(2).assigned_to
1599 1602 @request.session[:user_id] = 2
1600 1603 # unassign issues
1601 1604 post :bulk_update, :ids => [1, 2], :notes => 'Bulk unassigning', :issue => {:assigned_to_id => 'none'}
1602 1605 assert_response 302
1603 1606 # check that the issues were updated
1604 1607 assert_nil Issue.find(2).assigned_to
1605 1608 end
1606 1609
1607 1610 def test_post_bulk_update_should_allow_fixed_version_to_be_set_to_a_subproject
1608 1611 @request.session[:user_id] = 2
1609 1612
1610 1613 post :bulk_update, :ids => [1,2], :issue => {:fixed_version_id => 4}
1611 1614
1612 1615 assert_response :redirect
1613 1616 issues = Issue.find([1,2])
1614 1617 issues.each do |issue|
1615 1618 assert_equal 4, issue.fixed_version_id
1616 1619 assert_not_equal issue.project_id, issue.fixed_version.project_id
1617 1620 end
1618 1621 end
1619 1622
1620 1623 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
1621 1624 @request.session[:user_id] = 2
1622 1625 post :bulk_update, :ids => [1,2], :back_url => '/issues'
1623 1626
1624 1627 assert_response :redirect
1625 1628 assert_redirected_to '/issues'
1626 1629 end
1627 1630
1628 1631 def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
1629 1632 @request.session[:user_id] = 2
1630 1633 post :bulk_update, :ids => [1,2], :back_url => 'http://google.com'
1631 1634
1632 1635 assert_response :redirect
1633 1636 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier
1634 1637 end
1635 1638
1636 1639 def test_destroy_issue_with_no_time_entries
1637 1640 assert_nil TimeEntry.find_by_issue_id(2)
1638 1641 @request.session[:user_id] = 2
1639 1642 post :destroy, :id => 2
1640 1643 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
1641 1644 assert_nil Issue.find_by_id(2)
1642 1645 end
1643 1646
1644 1647 def test_destroy_issues_with_time_entries
1645 1648 @request.session[:user_id] = 2
1646 1649 post :destroy, :ids => [1, 3]
1647 1650 assert_response :success
1648 1651 assert_template 'destroy'
1649 1652 assert_not_nil assigns(:hours)
1650 1653 assert Issue.find_by_id(1) && Issue.find_by_id(3)
1651 1654 end
1652 1655
1653 1656 def test_destroy_issues_and_destroy_time_entries
1654 1657 @request.session[:user_id] = 2
1655 1658 post :destroy, :ids => [1, 3], :todo => 'destroy'
1656 1659 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
1657 1660 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
1658 1661 assert_nil TimeEntry.find_by_id([1, 2])
1659 1662 end
1660 1663
1661 1664 def test_destroy_issues_and_assign_time_entries_to_project
1662 1665 @request.session[:user_id] = 2
1663 1666 post :destroy, :ids => [1, 3], :todo => 'nullify'
1664 1667 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
1665 1668 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
1666 1669 assert_nil TimeEntry.find(1).issue_id
1667 1670 assert_nil TimeEntry.find(2).issue_id
1668 1671 end
1669 1672
1670 1673 def test_destroy_issues_and_reassign_time_entries_to_another_issue
1671 1674 @request.session[:user_id] = 2
1672 1675 post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
1673 1676 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
1674 1677 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
1675 1678 assert_equal 2, TimeEntry.find(1).issue_id
1676 1679 assert_equal 2, TimeEntry.find(2).issue_id
1677 1680 end
1678 1681
1679 1682 def test_destroy_issues_from_different_projects
1680 1683 @request.session[:user_id] = 2
1681 1684 post :destroy, :ids => [1, 2, 6], :todo => 'destroy'
1682 1685 assert_redirected_to :controller => 'issues', :action => 'index'
1683 1686 assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
1684 1687 end
1685 1688
1686 1689 def test_destroy_parent_and_child_issues
1687 1690 parent = Issue.generate!(:project_id => 1, :tracker_id => 1)
1688 1691 child = Issue.generate!(:project_id => 1, :tracker_id => 1, :parent_issue_id => parent.id)
1689 1692 assert child.is_descendant_of?(parent.reload)
1690 1693
1691 1694 @request.session[:user_id] = 2
1692 1695 assert_difference 'Issue.count', -2 do
1693 1696 post :destroy, :ids => [parent.id, child.id], :todo => 'destroy'
1694 1697 end
1695 1698 assert_response 302
1696 1699 end
1697 1700
1698 1701 def test_default_search_scope
1699 1702 get :index
1700 1703 assert_tag :div, :attributes => {:id => 'quick-search'},
1701 1704 :child => {:tag => 'form',
1702 1705 :child => {:tag => 'input', :attributes => {:name => 'issues', :type => 'hidden', :value => '1'}}}
1703 1706 end
1704 1707 end
General Comments 0
You need to be logged in to leave comments. Login now