comparison test/functional/issues_controller_test.rb @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents 0c939c159af4
children 5f33065ddc4b
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
41 :time_entries, 41 :time_entries,
42 :journals, 42 :journals,
43 :journal_details, 43 :journal_details,
44 :queries 44 :queries
45 45
46 include Redmine::I18n
47
46 def setup 48 def setup
47 @controller = IssuesController.new 49 @controller = IssuesController.new
48 @request = ActionController::TestRequest.new 50 @request = ActionController::TestRequest.new
49 @response = ActionController::TestResponse.new 51 @response = ActionController::TestResponse.new
50 User.current = nil 52 User.current = nil
53 def test_index 55 def test_index
54 Setting.default_language = 'en' 56 Setting.default_language = 'en'
55 57
56 get :index 58 get :index
57 assert_response :success 59 assert_response :success
58 assert_template 'index.rhtml' 60 assert_template 'index'
59 assert_not_nil assigns(:issues) 61 assert_not_nil assigns(:issues)
60 assert_nil assigns(:project) 62 assert_nil assigns(:project)
61 assert_tag :tag => 'a', :content => /Can't print recipes/ 63 assert_tag :tag => 'a', :content => /Can't print recipes/
62 assert_tag :tag => 'a', :content => /Subproject issue/ 64 assert_tag :tag => 'a', :content => /Subproject issue/
63 # private projects hidden 65 # private projects hidden
69 71
70 def test_index_should_not_list_issues_when_module_disabled 72 def test_index_should_not_list_issues_when_module_disabled
71 EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1") 73 EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
72 get :index 74 get :index
73 assert_response :success 75 assert_response :success
74 assert_template 'index.rhtml' 76 assert_template 'index'
75 assert_not_nil assigns(:issues) 77 assert_not_nil assigns(:issues)
76 assert_nil assigns(:project) 78 assert_nil assigns(:project)
77 assert_no_tag :tag => 'a', :content => /Can't print recipes/ 79 assert_no_tag :tag => 'a', :content => /Can't print recipes/
78 assert_tag :tag => 'a', :content => /Subproject issue/ 80 assert_tag :tag => 'a', :content => /Subproject issue/
79 end 81 end
80 82
81 def test_index_should_not_list_issues_when_module_disabled
82 EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
83 get :index
84 assert_response :success
85 assert_template 'index.rhtml'
86 assert_not_nil assigns(:issues)
87 assert_nil assigns(:project)
88 assert_no_tag :tag => 'a', :content => /Can't print recipes/
89 assert_tag :tag => 'a', :content => /Subproject issue/
90 end
91
92 def test_index_should_list_visible_issues_only 83 def test_index_should_list_visible_issues_only
93 get :index, :per_page => 100 84 get :index, :per_page => 100
94 assert_response :success 85 assert_response :success
95 assert_not_nil assigns(:issues) 86 assert_not_nil assigns(:issues)
96 assert_nil assigns(:issues).detect {|issue| !issue.visible?} 87 assert_nil assigns(:issues).detect {|issue| !issue.visible?}
98 89
99 def test_index_with_project 90 def test_index_with_project
100 Setting.display_subprojects_issues = 0 91 Setting.display_subprojects_issues = 0
101 get :index, :project_id => 1 92 get :index, :project_id => 1
102 assert_response :success 93 assert_response :success
103 assert_template 'index.rhtml' 94 assert_template 'index'
104 assert_not_nil assigns(:issues) 95 assert_not_nil assigns(:issues)
105 assert_tag :tag => 'a', :content => /Can't print recipes/ 96 assert_tag :tag => 'a', :content => /Can't print recipes/
106 assert_no_tag :tag => 'a', :content => /Subproject issue/ 97 assert_no_tag :tag => 'a', :content => /Subproject issue/
107 end 98 end
108 99
109 def test_index_with_project_and_subprojects 100 def test_index_with_project_and_subprojects
110 Setting.display_subprojects_issues = 1 101 Setting.display_subprojects_issues = 1
111 get :index, :project_id => 1 102 get :index, :project_id => 1
112 assert_response :success 103 assert_response :success
113 assert_template 'index.rhtml' 104 assert_template 'index'
114 assert_not_nil assigns(:issues) 105 assert_not_nil assigns(:issues)
115 assert_tag :tag => 'a', :content => /Can't print recipes/ 106 assert_tag :tag => 'a', :content => /Can't print recipes/
116 assert_tag :tag => 'a', :content => /Subproject issue/ 107 assert_tag :tag => 'a', :content => /Subproject issue/
117 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/ 108 assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
118 end 109 end
120 def test_index_with_project_and_subprojects_should_show_private_subprojects 111 def test_index_with_project_and_subprojects_should_show_private_subprojects
121 @request.session[:user_id] = 2 112 @request.session[:user_id] = 2
122 Setting.display_subprojects_issues = 1 113 Setting.display_subprojects_issues = 1
123 get :index, :project_id => 1 114 get :index, :project_id => 1
124 assert_response :success 115 assert_response :success
125 assert_template 'index.rhtml' 116 assert_template 'index'
126 assert_not_nil assigns(:issues) 117 assert_not_nil assigns(:issues)
127 assert_tag :tag => 'a', :content => /Can't print recipes/ 118 assert_tag :tag => 'a', :content => /Can't print recipes/
128 assert_tag :tag => 'a', :content => /Subproject issue/ 119 assert_tag :tag => 'a', :content => /Subproject issue/
129 assert_tag :tag => 'a', :content => /Issue of a private subproject/ 120 assert_tag :tag => 'a', :content => /Issue of a private subproject/
130 end 121 end
131 122
132 def test_index_with_project_and_default_filter 123 def test_index_with_project_and_default_filter
133 get :index, :project_id => 1, :set_filter => 1 124 get :index, :project_id => 1, :set_filter => 1
134 assert_response :success 125 assert_response :success
135 assert_template 'index.rhtml' 126 assert_template 'index'
136 assert_not_nil assigns(:issues) 127 assert_not_nil assigns(:issues)
137 128
138 query = assigns(:query) 129 query = assigns(:query)
139 assert_not_nil query 130 assert_not_nil query
140 # default filter 131 # default filter
145 get :index, :project_id => 1, :set_filter => 1, 136 get :index, :project_id => 1, :set_filter => 1,
146 :f => ['tracker_id'], 137 :f => ['tracker_id'],
147 :op => {'tracker_id' => '='}, 138 :op => {'tracker_id' => '='},
148 :v => {'tracker_id' => ['1']} 139 :v => {'tracker_id' => ['1']}
149 assert_response :success 140 assert_response :success
150 assert_template 'index.rhtml' 141 assert_template 'index'
151 assert_not_nil assigns(:issues) 142 assert_not_nil assigns(:issues)
152 143
153 query = assigns(:query) 144 query = assigns(:query)
154 assert_not_nil query 145 assert_not_nil query
155 assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters) 146 assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters)
156 end 147 end
157 148
149 def test_index_with_short_filters
150
151 to_test = {
152 'status_id' => {
153 'o' => { :op => 'o', :values => [''] },
154 'c' => { :op => 'c', :values => [''] },
155 '7' => { :op => '=', :values => ['7'] },
156 '7|3|4' => { :op => '=', :values => ['7', '3', '4'] },
157 '=7' => { :op => '=', :values => ['7'] },
158 '!3' => { :op => '!', :values => ['3'] },
159 '!7|3|4' => { :op => '!', :values => ['7', '3', '4'] }},
160 'subject' => {
161 'This is a subject' => { :op => '=', :values => ['This is a subject'] },
162 'o' => { :op => '=', :values => ['o'] },
163 '~This is part of a subject' => { :op => '~', :values => ['This is part of a subject'] },
164 '!~This is part of a subject' => { :op => '!~', :values => ['This is part of a subject'] }},
165 'tracker_id' => {
166 '3' => { :op => '=', :values => ['3'] },
167 '=3' => { :op => '=', :values => ['3'] }},
168 'start_date' => {
169 '2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
170 '=2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
171 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
172 '<=2011-10-12' => { :op => '<=', :values => ['2011-10-12'] },
173 '><2011-10-01|2011-10-30' => { :op => '><', :values => ['2011-10-01', '2011-10-30'] },
174 '<t+2' => { :op => '<t+', :values => ['2'] },
175 '>t+2' => { :op => '>t+', :values => ['2'] },
176 't+2' => { :op => 't+', :values => ['2'] },
177 't' => { :op => 't', :values => [''] },
178 'w' => { :op => 'w', :values => [''] },
179 '>t-2' => { :op => '>t-', :values => ['2'] },
180 '<t-2' => { :op => '<t-', :values => ['2'] },
181 't-2' => { :op => 't-', :values => ['2'] }},
182 'created_on' => {
183 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
184 '<t+2' => { :op => '=', :values => ['<t+2'] },
185 '>t+2' => { :op => '=', :values => ['>t+2'] },
186 't+2' => { :op => 't', :values => ['+2'] }},
187 'cf_1' => {
188 'c' => { :op => '=', :values => ['c'] },
189 '!c' => { :op => '!', :values => ['c'] },
190 '!*' => { :op => '!*', :values => [''] },
191 '*' => { :op => '*', :values => [''] }},
192 'estimated_hours' => {
193 '=13.4' => { :op => '=', :values => ['13.4'] },
194 '>=45' => { :op => '>=', :values => ['45'] },
195 '<=125' => { :op => '<=', :values => ['125'] },
196 '><10.5|20.5' => { :op => '><', :values => ['10.5', '20.5'] },
197 '!*' => { :op => '!*', :values => [''] },
198 '*' => { :op => '*', :values => [''] }}
199 }
200
201 default_filter = { 'status_id' => {:operator => 'o', :values => [''] }}
202
203 to_test.each do |field, expression_and_expected|
204 expression_and_expected.each do |filter_expression, expected|
205
206 get :index, :set_filter => 1, field => filter_expression
207
208 assert_response :success
209 assert_template 'index'
210 assert_not_nil assigns(:issues)
211
212 query = assigns(:query)
213 assert_not_nil query
214 assert query.has_filter?(field)
215 assert_equal(default_filter.merge({field => {:operator => expected[:op], :values => expected[:values]}}), query.filters)
216 end
217 end
218
219 end
220
158 def test_index_with_project_and_empty_filters 221 def test_index_with_project_and_empty_filters
159 get :index, :project_id => 1, :set_filter => 1, :fields => [''] 222 get :index, :project_id => 1, :set_filter => 1, :fields => ['']
160 assert_response :success 223 assert_response :success
161 assert_template 'index.rhtml' 224 assert_template 'index'
162 assert_not_nil assigns(:issues) 225 assert_not_nil assigns(:issues)
163 226
164 query = assigns(:query) 227 query = assigns(:query)
165 assert_not_nil query 228 assert_not_nil query
166 # no filter 229 # no filter
168 end 231 end
169 232
170 def test_index_with_query 233 def test_index_with_query
171 get :index, :project_id => 1, :query_id => 5 234 get :index, :project_id => 1, :query_id => 5
172 assert_response :success 235 assert_response :success
173 assert_template 'index.rhtml' 236 assert_template 'index'
174 assert_not_nil assigns(:issues) 237 assert_not_nil assigns(:issues)
175 assert_nil assigns(:issue_count_by_group) 238 assert_nil assigns(:issue_count_by_group)
176 end 239 end
177 240
178 def test_index_with_query_grouped_by_tracker 241 def test_index_with_query_grouped_by_tracker
179 get :index, :project_id => 1, :query_id => 6 242 get :index, :project_id => 1, :query_id => 6
180 assert_response :success 243 assert_response :success
181 assert_template 'index.rhtml' 244 assert_template 'index'
182 assert_not_nil assigns(:issues) 245 assert_not_nil assigns(:issues)
183 assert_not_nil assigns(:issue_count_by_group) 246 assert_not_nil assigns(:issue_count_by_group)
184 end 247 end
185 248
186 def test_index_with_query_grouped_by_list_custom_field 249 def test_index_with_query_grouped_by_list_custom_field
187 get :index, :project_id => 1, :query_id => 9 250 get :index, :project_id => 1, :query_id => 9
188 assert_response :success 251 assert_response :success
189 assert_template 'index.rhtml' 252 assert_template 'index'
190 assert_not_nil assigns(:issues) 253 assert_not_nil assigns(:issues)
191 assert_not_nil assigns(:issue_count_by_group) 254 assert_not_nil assigns(:issue_count_by_group)
192 end 255 end
193 256
257 def test_index_with_query_id_and_project_id_should_set_session_query
258 get :index, :project_id => 1, :query_id => 4
259 assert_response :success
260 assert_kind_of Hash, session[:query]
261 assert_equal 4, session[:query][:id]
262 assert_equal 1, session[:query][:project_id]
263 end
264
265 def test_index_with_cross_project_query_in_session_should_show_project_issues
266 q = Query.create!(:name => "test", :user_id => 2, :is_public => false, :project => nil)
267 @request.session[:query] = {:id => q.id, :project_id => 1}
268
269 with_settings :display_subprojects_issues => '0' do
270 get :index, :project_id => 1
271 end
272 assert_response :success
273 assert_not_nil assigns(:query)
274 assert_equal q.id, assigns(:query).id
275 assert_equal 1, assigns(:query).project_id
276 assert_equal [1], assigns(:issues).map(&:project_id).uniq
277 end
278
194 def test_private_query_should_not_be_available_to_other_users 279 def test_private_query_should_not_be_available_to_other_users
195 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil) 280 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
196 @request.session[:user_id] = 3 281 @request.session[:user_id] = 3
197 282
198 get :index, :query_id => q.id 283 get :index, :query_id => q.id
199 assert_response 403 284 assert_response 403
200 end 285 end
201 286
202 def test_private_query_should_be_available_to_its_user 287 def test_private_query_should_be_available_to_its_user
203 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil) 288 q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
204 @request.session[:user_id] = 2 289 @request.session[:user_id] = 2
205 290
206 get :index, :query_id => q.id 291 get :index, :query_id => q.id
207 assert_response :success 292 assert_response :success
208 end 293 end
209 294
210 def test_public_query_should_be_available_to_other_users 295 def test_public_query_should_be_available_to_other_users
211 q = Query.create!(:name => "private", :user => User.find(2), :is_public => true, :project => nil) 296 q = Query.create!(:name => "private", :user => User.find(2), :is_public => true, :project => nil)
212 @request.session[:user_id] = 3 297 @request.session[:user_id] = 3
213 298
214 get :index, :query_id => q.id 299 get :index, :query_id => q.id
215 assert_response :success 300 assert_response :success
216 end 301 end
217 302
218 def test_index_sort_by_field_not_included_in_columns 303 def test_index_csv
219 Setting.issue_list_default_columns = %w(subject author)
220 get :index, :sort => 'tracker'
221 end
222
223 def test_index_csv_with_project
224 Setting.default_language = 'en'
225
226 get :index, :format => 'csv' 304 get :index, :format => 'csv'
227 assert_response :success 305 assert_response :success
228 assert_not_nil assigns(:issues) 306 assert_not_nil assigns(:issues)
229 assert_equal 'text/csv', @response.content_type 307 assert_equal 'text/csv', @response.content_type
230 assert @response.body.starts_with?("#,") 308 assert @response.body.starts_with?("#,")
231 309 lines = @response.body.chomp.split("\n")
310 assert_equal assigns(:query).columns.size + 1, lines[0].split(',').size
311 end
312
313 def test_index_csv_with_project
232 get :index, :project_id => 1, :format => 'csv' 314 get :index, :project_id => 1, :format => 'csv'
233 assert_response :success 315 assert_response :success
234 assert_not_nil assigns(:issues) 316 assert_not_nil assigns(:issues)
235 assert_equal 'text/csv', @response.content_type 317 assert_equal 'text/csv', @response.content_type
236 end 318 end
237 319
320 def test_index_csv_with_description
321 get :index, :format => 'csv', :description => '1'
322 assert_response :success
323 assert_not_nil assigns(:issues)
324 assert_equal 'text/csv', @response.content_type
325 assert @response.body.starts_with?("#,")
326 lines = @response.body.chomp.split("\n")
327 assert_equal assigns(:query).columns.size + 2, lines[0].split(',').size
328 end
329
330 def test_index_csv_with_all_columns
331 get :index, :format => 'csv', :columns => 'all'
332 assert_response :success
333 assert_not_nil assigns(:issues)
334 assert_equal 'text/csv', @response.content_type
335 assert @response.body.starts_with?("#,")
336 lines = @response.body.chomp.split("\n")
337 assert_equal assigns(:query).available_columns.size + 1, lines[0].split(',').size
338 end
339
340 def test_index_csv_big_5
341 with_settings :default_language => "zh-TW" do
342 str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88"
343 str_big5 = "\xa4@\xa4\xeb"
344 if str_utf8.respond_to?(:force_encoding)
345 str_utf8.force_encoding('UTF-8')
346 str_big5.force_encoding('Big5')
347 end
348 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
349 :status_id => 1, :priority => IssuePriority.all.first,
350 :subject => str_utf8)
351 assert issue.save
352
353 get :index, :project_id => 1,
354 :f => ['subject'],
355 :op => '=', :values => [str_utf8],
356 :format => 'csv'
357 assert_equal 'text/csv', @response.content_type
358 lines = @response.body.chomp.split("\n")
359 s1 = "\xaa\xac\xbaA"
360 if str_utf8.respond_to?(:force_encoding)
361 s1.force_encoding('Big5')
362 end
363 assert lines[0].include?(s1)
364 assert lines[1].include?(str_big5)
365 end
366 end
367
368 def test_index_csv_cannot_convert_should_be_replaced_big_5
369 with_settings :default_language => "zh-TW" do
370 str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85"
371 if str_utf8.respond_to?(:force_encoding)
372 str_utf8.force_encoding('UTF-8')
373 end
374 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
375 :status_id => 1, :priority => IssuePriority.all.first,
376 :subject => str_utf8)
377 assert issue.save
378
379 get :index, :project_id => 1,
380 :f => ['subject'],
381 :op => '=', :values => [str_utf8],
382 :c => ['status', 'subject'],
383 :format => 'csv',
384 :set_filter => 1
385 assert_equal 'text/csv', @response.content_type
386 lines = @response.body.chomp.split("\n")
387 s1 = "\xaa\xac\xbaA" # status
388 if str_utf8.respond_to?(:force_encoding)
389 s1.force_encoding('Big5')
390 end
391 assert lines[0].include?(s1)
392 s2 = lines[1].split(",")[2]
393 if s1.respond_to?(:force_encoding)
394 s3 = "\xa5H?" # subject
395 s3.force_encoding('Big5')
396 assert_equal s3, s2
397 elsif RUBY_PLATFORM == 'java'
398 assert_equal "??", s2
399 else
400 assert_equal "\xa5H???", s2
401 end
402 end
403 end
404
405 def test_index_csv_tw
406 with_settings :default_language => "zh-TW" do
407 str1 = "test_index_csv_tw"
408 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
409 :status_id => 1, :priority => IssuePriority.all.first,
410 :subject => str1, :estimated_hours => '1234.5')
411 assert issue.save
412 assert_equal 1234.5, issue.estimated_hours
413
414 get :index, :project_id => 1,
415 :f => ['subject'],
416 :op => '=', :values => [str1],
417 :c => ['estimated_hours', 'subject'],
418 :format => 'csv',
419 :set_filter => 1
420 assert_equal 'text/csv', @response.content_type
421 lines = @response.body.chomp.split("\n")
422 assert_equal "#{issue.id},1234.5,#{str1}", lines[1]
423
424 str_tw = "Traditional Chinese (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)"
425 if str_tw.respond_to?(:force_encoding)
426 str_tw.force_encoding('UTF-8')
427 end
428 assert_equal str_tw, l(:general_lang_name)
429 assert_equal ',', l(:general_csv_separator)
430 assert_equal '.', l(:general_csv_decimal_separator)
431 end
432 end
433
434 def test_index_csv_fr
435 with_settings :default_language => "fr" do
436 str1 = "test_index_csv_fr"
437 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
438 :status_id => 1, :priority => IssuePriority.all.first,
439 :subject => str1, :estimated_hours => '1234.5')
440 assert issue.save
441 assert_equal 1234.5, issue.estimated_hours
442
443 get :index, :project_id => 1,
444 :f => ['subject'],
445 :op => '=', :values => [str1],
446 :c => ['estimated_hours', 'subject'],
447 :format => 'csv',
448 :set_filter => 1
449 assert_equal 'text/csv', @response.content_type
450 lines = @response.body.chomp.split("\n")
451 assert_equal "#{issue.id};1234,5;#{str1}", lines[1]
452
453 str_fr = "Fran\xc3\xa7ais"
454 if str_fr.respond_to?(:force_encoding)
455 str_fr.force_encoding('UTF-8')
456 end
457 assert_equal str_fr, l(:general_lang_name)
458 assert_equal ';', l(:general_csv_separator)
459 assert_equal ',', l(:general_csv_decimal_separator)
460 end
461 end
462
238 def test_index_pdf 463 def test_index_pdf
239 get :index, :format => 'pdf' 464 ["en", "zh", "zh-TW", "ja", "ko"].each do |lang|
240 assert_response :success 465 with_settings :default_language => lang do
241 assert_not_nil assigns(:issues) 466
242 assert_equal 'application/pdf', @response.content_type 467 get :index
243 468 assert_response :success
244 get :index, :project_id => 1, :format => 'pdf' 469 assert_template 'index'
245 assert_response :success 470
246 assert_not_nil assigns(:issues) 471 if lang == "ja"
247 assert_equal 'application/pdf', @response.content_type 472 if RUBY_PLATFORM != 'java'
248 473 assert_equal "CP932", l(:general_pdf_encoding)
249 get :index, :project_id => 1, :query_id => 6, :format => 'pdf' 474 end
250 assert_response :success 475 if RUBY_PLATFORM == 'java' && l(:general_pdf_encoding) == "CP932"
251 assert_not_nil assigns(:issues) 476 next
252 assert_equal 'application/pdf', @response.content_type 477 end
478 end
479
480 get :index, :format => 'pdf'
481 assert_response :success
482 assert_not_nil assigns(:issues)
483 assert_equal 'application/pdf', @response.content_type
484
485 get :index, :project_id => 1, :format => 'pdf'
486 assert_response :success
487 assert_not_nil assigns(:issues)
488 assert_equal 'application/pdf', @response.content_type
489
490 get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
491 assert_response :success
492 assert_not_nil assigns(:issues)
493 assert_equal 'application/pdf', @response.content_type
494 end
495 end
253 end 496 end
254 497
255 def test_index_pdf_with_query_grouped_by_list_custom_field 498 def test_index_pdf_with_query_grouped_by_list_custom_field
256 get :index, :project_id => 1, :query_id => 9, :format => 'pdf' 499 get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
257 assert_response :success 500 assert_response :success
270 513
271 issues = assigns(:issues) 514 issues = assigns(:issues)
272 assert_not_nil issues 515 assert_not_nil issues
273 assert !issues.empty? 516 assert !issues.empty?
274 assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id) 517 assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
518 end
519
520 def test_index_sort_by_field_not_included_in_columns
521 Setting.issue_list_default_columns = %w(subject author)
522 get :index, :sort => 'tracker'
523 end
524
525 def test_index_sort_by_assigned_to
526 get :index, :sort => 'assigned_to'
527 assert_response :success
528 assignees = assigns(:issues).collect(&:assigned_to).compact
529 assert_equal assignees.sort, assignees
530 end
531
532 def test_index_sort_by_assigned_to_desc
533 get :index, :sort => 'assigned_to:desc'
534 assert_response :success
535 assignees = assigns(:issues).collect(&:assigned_to).compact
536 assert_equal assignees.sort.reverse, assignees
537 end
538
539 def test_index_group_by_assigned_to
540 get :index, :group_by => 'assigned_to', :sort => 'priority'
541 assert_response :success
542 end
543
544 def test_index_sort_by_author
545 get :index, :sort => 'author'
546 assert_response :success
547 authors = assigns(:issues).collect(&:author)
548 assert_equal authors.sort, authors
549 end
550
551 def test_index_sort_by_author_desc
552 get :index, :sort => 'author:desc'
553 assert_response :success
554 authors = assigns(:issues).collect(&:author)
555 assert_equal authors.sort.reverse, authors
556 end
557
558 def test_index_group_by_author
559 get :index, :group_by => 'author', :sort => 'priority'
560 assert_response :success
275 end 561 end
276 562
277 def test_index_with_columns 563 def test_index_with_columns
278 columns = ['tracker', 'subject', 'assigned_to'] 564 columns = ['tracker', 'subject', 'assigned_to']
279 get :index, :set_filter => 1, :c => columns 565 get :index, :set_filter => 1, :c => columns
294 :children => { :count => 3 } 580 :children => { :count => 3 }
295 assert_no_tag :tag => 'option', :attributes => { :value => 'project' }, 581 assert_no_tag :tag => 'option', :attributes => { :value => 'project' },
296 :parent => { :tag => 'select', :attributes => { :id => "selected_columns" } } 582 :parent => { :tag => 'select', :attributes => { :id => "selected_columns" } }
297 end 583 end
298 584
585 def test_index_without_project_should_implicitly_add_project_column_to_default_columns
586 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
587 get :index, :set_filter => 1
588
589 # query should use specified columns
590 query = assigns(:query)
591 assert_kind_of Query, query
592 assert_equal [:project, :tracker, :subject, :assigned_to], query.columns.map(&:name)
593 end
594
595 def test_index_without_project_and_explicit_default_columns_should_not_add_project_column
596 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
597 columns = ['tracker', 'subject', 'assigned_to']
598 get :index, :set_filter => 1, :c => columns
599
600 # query should use specified columns
601 query = assigns(:query)
602 assert_kind_of Query, query
603 assert_equal columns.map(&:to_sym), query.columns.map(&:name)
604 end
605
299 def test_index_with_custom_field_column 606 def test_index_with_custom_field_column
300 columns = %w(tracker subject cf_2) 607 columns = %w(tracker subject cf_2)
301 get :index, :set_filter => 1, :c => columns 608 get :index, :set_filter => 1, :c => columns
302 assert_response :success 609 assert_response :success
303 610
309 assert_tag :td, 616 assert_tag :td,
310 :attributes => {:class => 'cf_2 string'}, 617 :attributes => {:class => 'cf_2 string'},
311 :ancestor => {:tag => 'table', :attributes => {:class => /issues/}} 618 :ancestor => {:tag => 'table', :attributes => {:class => /issues/}}
312 end 619 end
313 620
621 def test_index_with_date_column
622 Issue.find(1).update_attribute :start_date, '1987-08-24'
623
624 with_settings :date_format => '%d/%m/%Y' do
625 get :index, :set_filter => 1, :c => %w(start_date)
626 assert_tag 'td', :attributes => {:class => /start_date/}, :content => '24/08/1987'
627 end
628 end
629
630 def test_index_with_done_ratio
631 Issue.find(1).update_attribute :done_ratio, 40
632
633 get :index, :set_filter => 1, :c => %w(done_ratio)
634 assert_tag 'td', :attributes => {:class => /done_ratio/},
635 :child => {:tag => 'table', :attributes => {:class => 'progress'},
636 :descendant => {:tag => 'td', :attributes => {:class => 'closed', :style => 'width: 40%;'}}
637 }
638 end
639
640 def test_index_with_fixed_version
641 get :index, :set_filter => 1, :c => %w(fixed_version)
642 assert_tag 'td', :attributes => {:class => /fixed_version/},
643 :child => {:tag => 'a', :content => '1.0', :attributes => {:href => '/versions/2'}}
644 end
645
646 def test_index_send_html_if_query_is_invalid
647 get :index, :f => ['start_date'], :op => {:start_date => '='}
648 assert_equal 'text/html', @response.content_type
649 assert_template 'index'
650 end
651
652 def test_index_send_nothing_if_query_is_invalid
653 get :index, :f => ['start_date'], :op => {:start_date => '='}, :format => 'csv'
654 assert_equal 'text/csv', @response.content_type
655 assert @response.body.blank?
656 end
657
314 def test_show_by_anonymous 658 def test_show_by_anonymous
315 get :show, :id => 1 659 get :show, :id => 1
316 assert_response :success 660 assert_response :success
317 assert_template 'show.rhtml' 661 assert_template 'show'
318 assert_not_nil assigns(:issue) 662 assert_not_nil assigns(:issue)
319 assert_equal Issue.find(1), assigns(:issue) 663 assert_equal Issue.find(1), assigns(:issue)
320 664
321 # anonymous role is allowed to add a note 665 # anonymous role is allowed to add a note
322 assert_tag :tag => 'form', 666 assert_tag :tag => 'form',
323 :descendant => { :tag => 'fieldset', 667 :descendant => { :tag => 'fieldset',
324 :child => { :tag => 'legend', 668 :child => { :tag => 'legend',
325 :content => /Notes/ } } 669 :content => /Notes/ } }
670 assert_tag :tag => 'title',
671 :content => "Bug #1: Can't print recipes - eCookbook - Redmine"
326 end 672 end
327 673
328 def test_show_by_manager 674 def test_show_by_manager
329 @request.session[:user_id] = 2 675 @request.session[:user_id] = 2
330 get :show, :id => 1 676 get :show, :id => 1
343 :descendant => { :tag => 'fieldset', 689 :descendant => { :tag => 'fieldset',
344 :child => { :tag => 'legend', 690 :child => { :tag => 'legend',
345 :content => /Notes/ } } 691 :content => /Notes/ } }
346 end 692 end
347 693
694 def test_update_form_should_not_display_inactive_enumerations
695 @request.session[:user_id] = 2
696 get :show, :id => 1
697 assert_response :success
698
699 assert ! IssuePriority.find(15).active?
700 assert_no_tag :option, :attributes => {:value => '15'},
701 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
702 end
703
704 def test_update_form_should_allow_attachment_upload
705 @request.session[:user_id] = 2
706 get :show, :id => 1
707
708 assert_tag :tag => 'form',
709 :attributes => {:id => 'issue-form', :method => 'post', :enctype => 'multipart/form-data'},
710 :descendant => {
711 :tag => 'input',
712 :attributes => {:type => 'file', :name => 'attachments[1][file]'}
713 }
714 end
715
348 def test_show_should_deny_anonymous_access_without_permission 716 def test_show_should_deny_anonymous_access_without_permission
349 Role.anonymous.remove_permission!(:view_issues) 717 Role.anonymous.remove_permission!(:view_issues)
350 get :show, :id => 1 718 get :show, :id => 1
351 assert_response :redirect 719 assert_response :redirect
352 end 720 end
423 end 791 end
424 792
425 def test_show_atom 793 def test_show_atom
426 get :show, :id => 2, :format => 'atom' 794 get :show, :id => 2, :format => 'atom'
427 assert_response :success 795 assert_response :success
428 assert_template 'journals/index.rxml' 796 assert_template 'journals/index'
429 # Inline image 797 # Inline image
430 assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10')) 798 assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
431 end 799 end
432 800
433 def test_show_export_to_pdf 801 def test_show_export_to_pdf
444 assert_response :success 812 assert_response :success
445 assert_template 'new' 813 assert_template 'new'
446 814
447 assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]', 815 assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
448 :value => 'Default string' } 816 :value => 'Default string' }
817
818 # Be sure we don't display inactive IssuePriorities
819 assert ! IssuePriority.find(15).active?
820 assert_no_tag :option, :attributes => {:value => '15'},
821 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
822 end
823
824 def test_get_new_without_default_start_date_is_creation_date
825 Setting.default_issue_start_date_to_creation_date = 0
826
827 @request.session[:user_id] = 2
828 get :new, :project_id => 1, :tracker_id => 1
829 assert_response :success
830 assert_template 'new'
831
832 assert_tag :tag => 'input', :attributes => { :name => 'issue[start_date]',
833 :value => nil }
834 end
835
836 def test_get_new_with_default_start_date_is_creation_date
837 Setting.default_issue_start_date_to_creation_date = 1
838
839 @request.session[:user_id] = 2
840 get :new, :project_id => 1, :tracker_id => 1
841 assert_response :success
842 assert_template 'new'
843
844 assert_tag :tag => 'input', :attributes => { :name => 'issue[start_date]',
845 :value => Date.today.to_s }
846 end
847
848 def test_get_new_form_should_allow_attachment_upload
849 @request.session[:user_id] = 2
850 get :new, :project_id => 1, :tracker_id => 1
851
852 assert_tag :tag => 'form',
853 :attributes => {:id => 'issue-form', :method => 'post', :enctype => 'multipart/form-data'},
854 :descendant => {
855 :tag => 'input',
856 :attributes => {:type => 'file', :name => 'attachments[1][file]'}
857 }
449 end 858 end
450 859
451 def test_get_new_without_tracker_id 860 def test_get_new_without_tracker_id
452 @request.session[:user_id] = 2 861 @request.session[:user_id] = 2
453 get :new, :project_id => 1 862 get :new, :project_id => 1
519 v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2}) 928 v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
520 assert_not_nil v 929 assert_not_nil v
521 assert_equal 'Value for field 2', v.value 930 assert_equal 'Value for field 2', v.value
522 end 931 end
523 932
524 def test_post_create_without_start_date 933 def test_post_new_with_group_assignment
934 group = Group.find(11)
935 project = Project.find(1)
936 project.members << Member.new(:principal => group, :roles => [Role.first])
937
938 with_settings :issue_group_assignment => '1' do
939 @request.session[:user_id] = 2
940 assert_difference 'Issue.count' do
941 post :create, :project_id => project.id,
942 :issue => {:tracker_id => 3,
943 :status_id => 1,
944 :subject => 'This is the test_new_with_group_assignment issue',
945 :assigned_to_id => group.id}
946 end
947 end
948 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
949
950 issue = Issue.find_by_subject('This is the test_new_with_group_assignment issue')
951 assert_not_nil issue
952 assert_equal group, issue.assigned_to
953 end
954
955 def test_post_create_without_start_date_and_default_start_date_is_not_creation_date
956 Setting.default_issue_start_date_to_creation_date = 0
957
525 @request.session[:user_id] = 2 958 @request.session[:user_id] = 2
526 assert_difference 'Issue.count' do 959 assert_difference 'Issue.count' do
527 post :create, :project_id => 1, 960 post :create, :project_id => 1,
528 :issue => {:tracker_id => 3, 961 :issue => {:tracker_id => 3,
529 :status_id => 2, 962 :status_id => 2,
530 :subject => 'This is the test_new issue', 963 :subject => 'This is the test_new issue',
531 :description => 'This is the description', 964 :description => 'This is the description',
532 :priority_id => 5, 965 :priority_id => 5,
533 :start_date => '',
534 :estimated_hours => '', 966 :estimated_hours => '',
535 :custom_field_values => {'2' => 'Value for field 2'}} 967 :custom_field_values => {'2' => 'Value for field 2'}}
536 end 968 end
537 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id 969 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
538 970
539 issue = Issue.find_by_subject('This is the test_new issue') 971 issue = Issue.find_by_subject('This is the test_new issue')
540 assert_not_nil issue 972 assert_not_nil issue
541 assert_nil issue.start_date 973 assert_nil issue.start_date
542 end 974 end
543 975
976 def test_post_create_without_start_date_and_default_start_date_is_creation_date
977 Setting.default_issue_start_date_to_creation_date = 1
978
979 @request.session[:user_id] = 2
980 assert_difference 'Issue.count' do
981 post :create, :project_id => 1,
982 :issue => {:tracker_id => 3,
983 :status_id => 2,
984 :subject => 'This is the test_new issue',
985 :description => 'This is the description',
986 :priority_id => 5,
987 :estimated_hours => '',
988 :custom_field_values => {'2' => 'Value for field 2'}}
989 end
990 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
991
992 issue = Issue.find_by_subject('This is the test_new issue')
993 assert_not_nil issue
994 assert_equal Date.today, issue.start_date
995 end
996
544 def test_post_create_and_continue 997 def test_post_create_and_continue
545 @request.session[:user_id] = 2 998 @request.session[:user_id] = 2
546 post :create, :project_id => 1, 999 assert_difference 'Issue.count' do
547 :issue => {:tracker_id => 3, 1000 post :create, :project_id => 1,
548 :subject => 'This is first issue', 1001 :issue => {:tracker_id => 3, :subject => 'This is first issue', :priority_id => 5},
549 :priority_id => 5}, 1002 :continue => ''
550 :continue => '' 1003 end
551 assert_redirected_to :controller => 'issues', :action => 'new', :project_id => 'ecookbook', 1004
552 :issue => {:tracker_id => 3} 1005 issue = Issue.first(:order => 'id DESC')
1006 assert_redirected_to :controller => 'issues', :action => 'new', :project_id => 'ecookbook', :issue => {:tracker_id => 3}
1007 assert_not_nil flash[:notice], "flash was not set"
1008 assert flash[:notice].include?("<a href='/issues/#{issue.id}'>##{issue.id}</a>"), "issue link not found in flash: #{flash[:notice]}"
553 end 1009 end
554 1010
555 def test_post_create_without_custom_fields_param 1011 def test_post_create_without_custom_fields_param
556 @request.session[:user_id] = 2 1012 @request.session[:user_id] = 2
557 assert_difference 'Issue.count' do 1013 assert_difference 'Issue.count' do
631 end 1087 end
632 issue = Issue.find_by_subject('This is a child issue') 1088 issue = Issue.find_by_subject('This is a child issue')
633 assert_not_nil issue 1089 assert_not_nil issue
634 assert_nil issue.parent 1090 assert_nil issue.parent
635 end 1091 end
636 1092
637 def test_post_create_private 1093 def test_post_create_private
638 @request.session[:user_id] = 2 1094 @request.session[:user_id] = 2
639 1095
640 assert_difference 'Issue.count' do 1096 assert_difference 'Issue.count' do
641 post :create, :project_id => 1, 1097 post :create, :project_id => 1,
644 :is_private => '1'} 1100 :is_private => '1'}
645 end 1101 end
646 issue = Issue.first(:order => 'id DESC') 1102 issue = Issue.first(:order => 'id DESC')
647 assert issue.is_private? 1103 assert issue.is_private?
648 end 1104 end
649 1105
650 def test_post_create_private_with_set_own_issues_private_permission 1106 def test_post_create_private_with_set_own_issues_private_permission
651 role = Role.find(1) 1107 role = Role.find(1)
652 role.remove_permission! :set_issues_private 1108 role.remove_permission! :set_issues_private
653 role.add_permission! :set_own_issues_private 1109 role.add_permission! :set_own_issues_private
654 1110
655 @request.session[:user_id] = 2 1111 @request.session[:user_id] = 2
656 1112
657 assert_difference 'Issue.count' do 1113 assert_difference 'Issue.count' do
658 post :create, :project_id => 1, 1114 post :create, :project_id => 1,
659 :issue => {:tracker_id => 1, 1115 :issue => {:tracker_id => 1,
713 assert_nothing_raised do 1169 assert_nothing_raised do
714 post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" } 1170 post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
715 end 1171 end
716 end 1172 end
717 1173
1174 def test_post_create_with_attachment
1175 set_tmp_attachments_directory
1176 @request.session[:user_id] = 2
1177
1178 assert_difference 'Issue.count' do
1179 assert_difference 'Attachment.count' do
1180 post :create, :project_id => 1,
1181 :issue => { :tracker_id => '1', :subject => 'With attachment' },
1182 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
1183 end
1184 end
1185
1186 issue = Issue.first(:order => 'id DESC')
1187 attachment = Attachment.first(:order => 'id DESC')
1188
1189 assert_equal issue, attachment.container
1190 assert_equal 2, attachment.author_id
1191 assert_equal 'testfile.txt', attachment.filename
1192 assert_equal 'text/plain', attachment.content_type
1193 assert_equal 'test file', attachment.description
1194 assert_equal 59, attachment.filesize
1195 assert File.exists?(attachment.diskfile)
1196 assert_equal 59, File.size(attachment.diskfile)
1197 end
1198
718 context "without workflow privilege" do 1199 context "without workflow privilege" do
719 setup do 1200 setup do
720 Workflow.delete_all(["role_id = ?", Role.anonymous.id]) 1201 Workflow.delete_all(["role_id = ?", Role.anonymous.id])
721 Role.anonymous.add_permission! :add_issues, :add_issue_notes 1202 Role.anonymous.add_permission! :add_issues, :add_issue_notes
722 end 1203 end
858 get :edit, :id => 1 1339 get :edit, :id => 1
859 assert_response :success 1340 assert_response :success
860 assert_template 'edit' 1341 assert_template 'edit'
861 assert_not_nil assigns(:issue) 1342 assert_not_nil assigns(:issue)
862 assert_equal Issue.find(1), assigns(:issue) 1343 assert_equal Issue.find(1), assigns(:issue)
1344
1345 # Be sure we don't display inactive IssuePriorities
1346 assert ! IssuePriority.find(15).active?
1347 assert_no_tag :option, :attributes => {:value => '15'},
1348 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
1349 end
1350
1351 def test_get_edit_should_display_the_time_entry_form_with_log_time_permission
1352 @request.session[:user_id] = 2
1353 Role.find_by_name('Manager').update_attribute :permissions, [:view_issues, :edit_issues, :log_time]
1354
1355 get :edit, :id => 1
1356 assert_tag 'input', :attributes => {:name => 'time_entry[hours]'}
1357 end
1358
1359 def test_get_edit_should_not_display_the_time_entry_form_without_log_time_permission
1360 @request.session[:user_id] = 2
1361 Role.find_by_name('Manager').remove_permission! :log_time
1362
1363 get :edit, :id => 1
1364 assert_no_tag 'input', :attributes => {:name => 'time_entry[hours]'}
863 end 1365 end
864 1366
865 def test_get_edit_with_params 1367 def test_get_edit_with_params
866 @request.session[:user_id] = 2 1368 @request.session[:user_id] = 2
867 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }, 1369 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 },
1045 # Delete all fixtured journals, a race condition can occur causing the wrong 1547 # Delete all fixtured journals, a race condition can occur causing the wrong
1046 # journal to get fetched in the next find. 1548 # journal to get fetched in the next find.
1047 Journal.delete_all 1549 Journal.delete_all
1048 1550
1049 # anonymous user 1551 # anonymous user
1050 put :update, 1552 assert_difference 'Attachment.count' do
1051 :id => 1, 1553 put :update, :id => 1,
1052 :notes => '', 1554 :notes => '',
1053 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} 1555 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
1556 end
1557
1054 assert_redirected_to :action => 'show', :id => '1' 1558 assert_redirected_to :action => 'show', :id => '1'
1055 j = Issue.find(1).journals.find(:first, :order => 'id DESC') 1559 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
1056 assert j.notes.blank? 1560 assert j.notes.blank?
1057 assert_equal 1, j.details.size 1561 assert_equal 1, j.details.size
1058 assert_equal 'testfile.txt', j.details.first.value 1562 assert_equal 'testfile.txt', j.details.first.value
1059 assert_equal User.anonymous, j.user 1563 assert_equal User.anonymous, j.user
1564
1565 attachment = Attachment.first(:order => 'id DESC')
1566 assert_equal Issue.find(1), attachment.container
1567 assert_equal User.anonymous, attachment.author
1568 assert_equal 'testfile.txt', attachment.filename
1569 assert_equal 'text/plain', attachment.content_type
1570 assert_equal 'test file', attachment.description
1571 assert_equal 59, attachment.filesize
1572 assert File.exists?(attachment.diskfile)
1573 assert_equal 59, File.size(attachment.diskfile)
1060 1574
1061 mail = ActionMailer::Base.deliveries.last 1575 mail = ActionMailer::Base.deliveries.last
1062 assert mail.body.include?('testfile.txt') 1576 assert mail.body.include?('testfile.txt')
1063 end 1577 end
1064 1578
1210 assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'} 1724 assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
1211 1725
1212 # System wide custom field 1726 # System wide custom field
1213 assert CustomField.find(1).is_for_all? 1727 assert CustomField.find(1).is_for_all?
1214 assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'} 1728 assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
1729
1730 # Be sure we don't display inactive IssuePriorities
1731 assert ! IssuePriority.find(15).active?
1732 assert_no_tag :option, :attributes => {:value => '15'},
1733 :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} }
1215 end 1734 end
1216 1735
1217 def test_get_bulk_edit_on_different_projects 1736 def test_get_bulk_edit_on_different_projects
1218 @request.session[:user_id] = 2 1737 @request.session[:user_id] = 2
1219 get :bulk_edit, :ids => [1, 2, 6] 1738 get :bulk_edit, :ids => [1, 2, 6]
1256 1775
1257 assert_tag :select, 1776 assert_tag :select,
1258 :attributes => {:name => "issue[custom_field_values][#{field.id}]"}, 1777 :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
1259 :children => { 1778 :children => {
1260 :only => {:tag => 'option'}, 1779 :only => {:tag => 'option'},
1261 :count => Project.find(1).versions.count + 1 1780 :count => Project.find(1).shared_versions.count + 1
1262 } 1781 }
1263 end 1782 end
1264 1783
1265 def test_bulk_update 1784 def test_bulk_update
1266 @request.session[:user_id] = 2 1785 @request.session[:user_id] = 2
1277 issue = Issue.find(1) 1796 issue = Issue.find(1)
1278 journal = issue.journals.find(:first, :order => 'created_on DESC') 1797 journal = issue.journals.find(:first, :order => 'created_on DESC')
1279 assert_equal '125', issue.custom_value_for(2).value 1798 assert_equal '125', issue.custom_value_for(2).value
1280 assert_equal 'Bulk editing', journal.notes 1799 assert_equal 'Bulk editing', journal.notes
1281 assert_equal 1, journal.details.size 1800 assert_equal 1, journal.details.size
1801 end
1802
1803 def test_bulk_update_with_group_assignee
1804 group = Group.find(11)
1805 project = Project.find(1)
1806 project.members << Member.new(:principal => group, :roles => [Role.first])
1807
1808 @request.session[:user_id] = 2
1809 # update issues assignee
1810 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
1811 :issue => {:priority_id => '',
1812 :assigned_to_id => group.id,
1813 :custom_field_values => {'2' => ''}}
1814
1815 assert_response 302
1816 assert_equal [group, group], Issue.find_all_by_id([1, 2]).collect {|i| i.assigned_to}
1282 end 1817 end
1283 1818
1284 def test_bulk_update_on_different_projects 1819 def test_bulk_update_on_different_projects
1285 @request.session[:user_id] = 2 1820 @request.session[:user_id] = 2
1286 # update issues priority 1821 # update issues priority