##// END OF EJS Templates
Gantt unit tests cleanup....
Jean-Philippe Lang -
r13291:dacae57a3873
parent child
Show More
This diff has been collapsed as it changes many lines, (525 lines changed) Show them Hide them
@@ -18,16 +18,8
18 require File.expand_path('../../../../../test_helper', __FILE__)
18 require File.expand_path('../../../../../test_helper', __FILE__)
19
19
20 class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
20 class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
21 fixtures :projects, :trackers, :issue_statuses, :issues,
21 fixtures :trackers, :issue_statuses,
22 :journals, :journal_details,
22 :enumerations, :users, :issue_categories
23 :enumerations, :users, :issue_categories,
24 :projects_trackers,
25 :roles,
26 :member_roles,
27 :members,
28 :enabled_modules,
29 :versions,
30 :groups_users
31
23
32 include ProjectsHelper
24 include ProjectsHelper
33 include IssuesHelper
25 include IssuesHelper
@@ -44,12 +36,16 class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
44 end
36 end
45 private :today
37 private :today
46
38
39 def gantt_start
40 @gantt.date_from
41 end
42
47 # Creates a Gantt chart for a 4 week span
43 # Creates a Gantt chart for a 4 week span
48 def create_gantt(project=Project.generate!, options={})
44 def create_gantt(project=Project.generate!, options={})
49 @project = project
45 @project = project
50 @gantt = Redmine::Helpers::Gantt.new(options)
46 @gantt = Redmine::Helpers::Gantt.new(options)
51 @gantt.project = @project
47 @gantt.project = @project
52 @gantt.query = IssueQuery.create!(:project => @project, :name => 'Gantt')
48 @gantt.query = IssueQuery.new(:project => @project, :name => 'Gantt')
53 @gantt.view = self
49 @gantt.view = self
54 @gantt.instance_variable_set('@date_from', options[:date_from] || (today - 14))
50 @gantt.instance_variable_set('@date_from', options[:date_from] || (today - 14))
55 @gantt.instance_variable_set('@date_to', options[:date_to] || (today + 14))
51 @gantt.instance_variable_set('@date_to', options[:date_to] || (today + 14))
@@ -132,11 +128,6 class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
132 setup_subjects
128 setup_subjects
133 @output_buffer = @gantt.subjects
129 @output_buffer = @gantt.subjects
134 assert_select "div.project-name a", /#{@project.name}/
130 assert_select "div.project-name a", /#{@project.name}/
135 end
136
137 test "#subjects project should have an indent of 4" do
138 setup_subjects
139 @output_buffer = @gantt.subjects
140 assert_select "div.project-name[style*=left:4px]"
131 assert_select "div.project-name[style*=left:4px]"
141 end
132 end
142
133
@@ -144,11 +135,6 class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
144 setup_subjects
135 setup_subjects
145 @output_buffer = @gantt.subjects
136 @output_buffer = @gantt.subjects
146 assert_select "div.version-name a", /#{@version.name}/
137 assert_select "div.version-name a", /#{@version.name}/
147 end
148
149 test "#subjects version should be indented 24 (one level)" do
150 setup_subjects
151 @output_buffer = @gantt.subjects
152 assert_select "div.version-name[style*=left:24px]"
138 assert_select "div.version-name[style*=left:24px]"
153 end
139 end
154
140
@@ -166,11 +152,6 class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
166 setup_subjects
152 setup_subjects
167 @output_buffer = @gantt.subjects
153 @output_buffer = @gantt.subjects
168 assert_select "div.issue-subject", /#{@issue.subject}/
154 assert_select "div.issue-subject", /#{@issue.subject}/
169 end
170
171 test "#subjects issue should be indented 44 (two levels)" do
172 setup_subjects
173 @output_buffer = @gantt.subjects
174 assert_select "div.issue-subject[style*=left:44px]"
155 assert_select "div.issue-subject[style*=left:44px]"
175 end
156 end
176
157
@@ -224,8 +205,7 class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
224 assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @output_buffer
205 assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @output_buffer
225 end
206 end
226
207
227 context "#lines" do
208 test "#lines" do
228 setup do
229 create_gantt
209 create_gantt
230 @project.enabled_module_names = [:issue_tracking]
210 @project.enabled_module_names = [:issue_tracking]
231 @tracker = Tracker.generate!
211 @tracker = Tracker.generate!
@@ -241,443 +221,201 class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
241 :due_date => (today + 7))
221 :due_date => (today + 7))
242 @project.issues << @issue
222 @project.issues << @issue
243 @output_buffer = @gantt.lines
223 @output_buffer = @gantt.lines
244 end
245
224
246 context "project" do
247 should "be rendered" do
248 assert_select "div.project.task_todo"
225 assert_select "div.project.task_todo"
249 assert_select "div.project.starting"
226 assert_select "div.project.starting"
250 assert_select "div.project.ending"
227 assert_select "div.project.ending"
251 assert_select "div.label.project", /#{@project.name}/
228 assert_select "div.label.project", /#{@project.name}/
252 end
253 end
254
229
255 context "version" do
256 should "be rendered" do
257 assert_select "div.version.task_todo"
230 assert_select "div.version.task_todo"
258 assert_select "div.version.starting"
231 assert_select "div.version.starting"
259 assert_select "div.version.ending"
232 assert_select "div.version.ending"
260 assert_select "div.label.version", /#{@version.name}/
233 assert_select "div.label.version", /#{@version.name}/
261 end
262 end
263
234
264 context "issue" do
265 should "be rendered" do
266 assert_select "div.task_todo"
235 assert_select "div.task_todo"
267 assert_select "div.task.label", /#{@issue.done_ratio}/
236 assert_select "div.task.label", /#{@issue.done_ratio}/
268 assert_select "div.tooltip", /#{@issue.subject}/
237 assert_select "div.tooltip", /#{@issue.subject}/
269 end
238 end
270 end
271 end
272
239
273 context "#subject_for_project" do
240 test "#subject_for_project" do
274 setup do
275 create_gantt
241 create_gantt
276 end
242 @output_buffer = @gantt.subject_for_project(@project, :format => :html)
277
278 context ":html format" do
279 should "add an absolute positioned div" do
280 @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
281 assert_select "div[style*=absolute]"
282 end
283
284 should "use the indent option to move the div to the right" do
285 @output_buffer = @gantt.subject_for_project(@project, {:format => :html, :indent => 40})
286 assert_select "div[style*=left:40]"
287 end
288
289 should "include the project name" do
290 @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
291 assert_select 'div', :text => /#{@project.name}/
292 end
293
294 should "include a link to the project" do
295 @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
296 assert_select 'a[href=?]', "/projects/#{@project.identifier}", :text => /#{@project.name}/
243 assert_select 'a[href=?]', "/projects/#{@project.identifier}", :text => /#{@project.name}/
297 end
244 end
298
245
299 should "style overdue projects" do
246 test "#subject_for_project should style overdue projects" do
300 @project.enabled_module_names = [:issue_tracking]
247 create_gantt
301 @project.versions << Version.generate!(:effective_date => (today - 1))
248 @project.stubs(:overdue?).returns(true)
302 assert @project.reload.overdue?, "Need an overdue project for this test"
249 @output_buffer = @gantt.subject_for_project(@project, :format => :html)
303 @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
304 assert_select 'div span.project-overdue'
250 assert_select 'div span.project-overdue'
305 end
251 end
306 end
307 end
308
252
309 context "#line_for_project" do
253 test "#subject_for_version" do
310 setup do
311 create_gantt
254 create_gantt
312 @project.enabled_module_names = [:issue_tracking]
255 version = Version.generate!(:name => 'Foo', :effective_date => today, :project => @project)
313 @tracker = Tracker.generate!
256 @output_buffer = @gantt.subject_for_version(version, :format => :html)
314 @project.trackers << @tracker
257 assert_select 'a[href=?]', "/versions/#{version.to_param}", :text => /Foo/
315 @version = Version.generate!(:effective_date => (today - 1))
316 @project.versions << @version
317 @project.issues << Issue.generate!(:fixed_version => @version,
318 :subject => "gantt#line_for_project",
319 :tracker => @tracker,
320 :project => @project,
321 :done_ratio => 30,
322 :start_date => (today - 7),
323 :due_date => (today + 7))
324 end
258 end
325
259
326 context ":html format" do
260 test "#subject_for_version should style overdue versions" do
327 context "todo line" do
328 should "start from the starting point on the left" do
329 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
330 assert_select "div.project.task_todo[style*=left:28px]", true, @output_buffer
331 end
332
333 should "be the total width of the project" do
334 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
335 assert_select "div.project.task_todo[style*=width:58px]", true, @output_buffer
336 end
337 end
338
339 context "starting marker" do
340 should "not appear if the starting point is off the gantt chart" do
341 # Shift the date range of the chart
342 @gantt.instance_variable_set('@date_from', today)
343 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
344 assert_select "div.project.starting", false, @output_buffer
345 end
346
347 should "appear at the starting point" do
348 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
349 assert_select "div.project.starting[style*=left:28px]", true, @output_buffer
350 end
351 end
352
353 context "ending marker" do
354 should "not appear if the starting point is off the gantt chart" do
355 # Shift the date range of the chart
356 @gantt.instance_variable_set('@date_to', (today - 14))
357 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
358 assert_select "div.project.ending", false, @output_buffer
359 end
360
361 should "appear at the end of the date range" do
362 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
363 assert_select "div.project.ending[style*=left:88px]", true, @output_buffer
364 end
365 end
366
367 context "status content" do
368 should "appear at the far left, even if it's far in the past" do
369 @gantt.instance_variable_set('@date_to', (today - 14))
370 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
371 assert_select "div.project.label", /#{@project.name}/
372 end
373
374 should "show the project name" do
375 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
376 assert_select "div.project.label", /#{@project.name}/
377 end
378 end
379 end
380 end
381
382 context "#subject_for_version" do
383 setup do
384 create_gantt
261 create_gantt
385 @project.enabled_module_names = [:issue_tracking]
262 version = Version.generate!(:name => 'Foo', :effective_date => today, :project => @project)
386 @tracker = Tracker.generate!
263 version.stubs(:overdue?).returns(true)
387 @project.trackers << @tracker
264 @output_buffer = @gantt.subject_for_version(version, :format => :html)
388 @version = Version.generate!(:effective_date => (today - 1))
265 assert_select 'div span.version-overdue'
389 @project.versions << @version
390 @project.issues << Issue.generate!(:fixed_version => @version,
391 :subject => "gantt#subject_for_version",
392 :tracker => @tracker,
393 :project => @project,
394 :start_date => today)
395
396 end
397
398 context ":html format" do
399 should "add an absolute positioned div" do
400 @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
401 assert_select "div[style*=absolute]"
402 end
403
404 should "use the indent option to move the div to the right" do
405 @output_buffer = @gantt.subject_for_version(@version, {:format => :html, :indent => 40})
406 assert_select "div[style*=left:40]"
407 end
408
409 should "include the version name" do
410 @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
411 assert_select 'div', :text => /#{@version.name}/
412 end
413
414 should "include a link to the version" do
415 @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
416 assert_select 'a[href=?]', Regexp.escape("/versions/#{@version.to_param}"), :text => /#{@version.name}/
417 end
266 end
418
267
419 should "style late versions" do
268 test "#subject_for_version should style behind schedule versions" do
420 assert @version.overdue?, "Need an overdue version for this test"
269 create_gantt
421 @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
270 version = Version.generate!(:name => 'Foo', :effective_date => today, :project => @project)
271 version.stubs(:behind_schedule?).returns(true)
272 @output_buffer = @gantt.subject_for_version(version, :format => :html)
422 assert_select 'div span.version-behind-schedule'
273 assert_select 'div span.version-behind-schedule'
423 end
274 end
424
275
425 should "style behind schedule versions" do
276 test "#subject_for_issue" do
426 assert @version.behind_schedule?, "Need a behind schedule version for this test"
427 @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
428 assert_select 'div span.version-behind-schedule'
429 end
430 end
431 end
432
433 context "#line_for_version" do
434 setup do
435 create_gantt
277 create_gantt
436 @project.enabled_module_names = [:issue_tracking]
278 issue = Issue.generate!(:project => @project)
437 @tracker = Tracker.generate!
279 @output_buffer = @gantt.subject_for_issue(issue, :format => :html)
438 @project.trackers << @tracker
280 assert_select 'div', :text => /#{issue.subject}/
439 @version = Version.generate!(:effective_date => (today + 7))
281 assert_select 'a[href=?]', "/issues/#{issue.to_param}", :text => /#{issue.tracker.name} ##{issue.id}/
440 @project.versions << @version
441 @project.issues << Issue.generate!(:fixed_version => @version,
442 :subject => "gantt#line_for_project",
443 :tracker => @tracker,
444 :project => @project,
445 :done_ratio => 30,
446 :start_date => (today - 7),
447 :due_date => (today + 7))
448 end
449
450 context ":html format" do
451 context "todo line" do
452 should "start from the starting point on the left" do
453 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
454 assert_select "div.version.task_todo[style*=left:28px]", true, @output_buffer
455 end
456
457 should "be the total width of the version" do
458 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
459 assert_select "div.version.task_todo[style*=width:58px]", true, @output_buffer
460 end
461 end
462
463 context "late line" do
464 should "start from the starting point on the left" do
465 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
466 assert_select "div.version.task_late[style*=left:28px]", true, @output_buffer
467 end
468
469 should "be the total delayed width of the version" do
470 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
471 assert_select "div.version.task_late[style*=width:30px]", true, @output_buffer
472 end
473 end
474
475 context "done line" do
476 should "start from the starting point on the left" do
477 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
478 assert_select "div.version.task_done[style*=left:28px]", true, @output_buffer
479 end
480
481 should "be the total done width of the version" do
482 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
483 assert_select "div.version.task_done[style*=width:16px]", true, @output_buffer
484 end
485 end
486
487 context "starting marker" do
488 should "not appear if the starting point is off the gantt chart" do
489 # Shift the date range of the chart
490 @gantt.instance_variable_set('@date_from', today)
491 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
492 assert_select "div.version.starting", false
493 end
282 end
494
283
495 should "appear at the starting point" do
284 test "#subject_for_issue should style overdue issues" do
496 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
497 assert_select "div.version.starting[style*=left:28px]", true, @output_buffer
498 end
499 end
500
501 context "ending marker" do
502 should "not appear if the starting point is off the gantt chart" do
503 # Shift the date range of the chart
504 @gantt.instance_variable_set('@date_to', (today - 14))
505 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
506 assert_select "div.version.ending", false
507 end
508
509 should "appear at the end of the date range" do
510 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
511 assert_select "div.version.ending[style*=left:88px]", true, @output_buffer
512 end
513 end
514
515 context "status content" do
516 should "appear at the far left, even if it's far in the past" do
517 @gantt.instance_variable_set('@date_to', (today - 14))
518 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
519 assert_select "div.version.label", /#{@version.name}/
520 end
521
522 should "show the version name" do
523 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
524 assert_select "div.version.label", /#{@version.name}/
525 end
526
527 should "show the percent complete" do
528 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
529 assert_select "div.version.label", /30%/
530 end
531 end
532 end
533 end
534
535 context "#subject_for_issue" do
536 setup do
537 create_gantt
285 create_gantt
538 @project.enabled_module_names = [:issue_tracking]
286 issue = Issue.generate!(:project => @project)
539 @tracker = Tracker.generate!
287 issue.stubs(:overdue?).returns(true)
540 @project.trackers << @tracker
288 @output_buffer = @gantt.subject_for_issue(issue, :format => :html)
541 @issue = Issue.generate!(:subject => "gantt#subject_for_issue",
289 assert_select 'div span.issue-overdue'
542 :tracker => @tracker,
543 :project => @project,
544 :start_date => (today - 3),
545 :due_date => (today - 1))
546 @project.issues << @issue
547 end
290 end
548
291
549 context ":html format" do
292 test "#subject should add an absolute positioned div" do
550 should "add an absolute positioned div" do
293 create_gantt
551 @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
294 @output_buffer = @gantt.subject('subject', :format => :html)
552 assert_select "div[style*=absolute]"
295 assert_select "div[style*=absolute]", :text => 'subject'
553 end
296 end
554
297
555 should "use the indent option to move the div to the right" do
298 test "#subject should use the indent option to move the div to the right" do
556 @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html, :indent => 40})
299 create_gantt
300 @output_buffer = @gantt.subject('subject', :format => :html, :indent => 40)
557 assert_select "div[style*=left:40]"
301 assert_select "div[style*=left:40]"
558 end
302 end
559
303
560 should "include the issue subject" do
304 test "#line_for_project" do
561 @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
305 create_gantt
562 assert_select 'div', :text => /#{@issue.subject}/
306 @project.stubs(:start_date).returns(today - 7)
563 end
307 @project.stubs(:due_date).returns(today + 7)
564
308 @output_buffer = @gantt.line_for_project(@project, :format => :html)
565 should "include a link to the issue" do
309 assert_select "div.project.label", :text => @project.name
566 @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
567 assert_select 'a[href=?]', Regexp.escape("/issues/#{@issue.to_param}"), :text => /#{@tracker.name} ##{@issue.id}/
568 end
310 end
569
311
570 should "style overdue issues" do
312 test "#line_for_version" do
571 assert @issue.overdue?, "Need an overdue issue for this test"
313 create_gantt
572 @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
314 version = Version.generate!(:name => 'Foo', :project => @project)
573 assert_select 'div span.issue-overdue'
315 version.stubs(:start_date).returns(today - 7)
574 end
316 version.stubs(:due_date).returns(today + 7)
575 end
317 version.stubs(:completed_percent).returns(30)
318 @output_buffer = @gantt.line_for_version(version, :format => :html)
319 assert_select "div.version.label", :text => /Foo/
320 assert_select "div.version.label", :text => /30%/
576 end
321 end
577
322
578 context "#line_for_issue" do
323 test "#line_for_issue" do
579 setup do
580 create_gantt
324 create_gantt
581 @project.enabled_module_names = [:issue_tracking]
325 issue = Issue.generate!(:project => @project, :start_date => today - 7, :due_date => today + 7, :done_ratio => 30)
582 @tracker = Tracker.generate!
326 @output_buffer = @gantt.line_for_issue(issue, :format => :html)
583 @project.trackers << @tracker
327 assert_select "div.task.label", :text => /#{issue.status.name}/
584 @version = Version.generate!(:effective_date => (today + 7))
328 assert_select "div.task.label", :text => /30%/
585 @project.versions << @version
329 assert_select "div.tooltip", /#{issue.subject}/
586 @issue = Issue.generate!(:fixed_version => @version,
587 :subject => "gantt#line_for_project",
588 :tracker => @tracker,
589 :project => @project,
590 :done_ratio => 30,
591 :start_date => (today - 7),
592 :due_date => (today + 7))
593 @project.issues << @issue
594 end
330 end
595
331
596 context ":html format" do
332 test "#line todo line should start from the starting point on the left" do
597 context "todo line" do
333 create_gantt
598 should "start from the starting point on the left" do
334 @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
599 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
335 assert_select "div.task_todo[style*=left:28px]", 1
600 assert_select "div.task_todo[style*=left:28px]", true, @output_buffer
601 end
336 end
602
337
603 should "be the total width of the issue" do
338 test "#line todo line should be the total width" do
604 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
339 create_gantt
605 assert_select "div.task_todo[style*=width:58px]", true, @output_buffer
340 @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
606 end
341 assert_select "div.task_todo[style*=width:58px]", 1
607 end
342 end
608
343
609 context "late line" do
344 test "#line late line should start from the starting point on the left" do
610 should "start from the starting point on the left" do
345 create_gantt
611 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
346 @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
612 assert_select "div.task_late[style*=left:28px]", true, @output_buffer
347 assert_select "div.task_late[style*=left:28px]", 1
613 end
348 end
614
349
615 should "be the total delayed width of the issue" do
350 test "#line late line should be the total delayed width" do
616 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
351 create_gantt
617 assert_select "div.task_late[style*=width:30px]", true, @output_buffer
352 @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
618 end
353 assert_select "div.task_late[style*=width:30px]", 1
619 end
354 end
620
355
621 context "done line" do
356 test "#line done line should start from the starting point on the left" do
622 should "start from the starting point on the left" do
357 create_gantt
623 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
358 @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
624 assert_select "div.task_done[style*=left:28px]", true, @output_buffer
359 assert_select "div.task_done[style*=left:28px]", 1
625 end
360 end
626
361
627 should "be the total done width of the issue" do
362 test "#line done line should be the width for the done ratio" do
628 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
363 create_gantt
364 @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
629 # 15 days * 4 px * 30% - 2 px for borders = 16 px
365 # 15 days * 4 px * 30% - 2 px for borders = 16 px
630 assert_select "div.task_done[style*=width:16px]", true, @output_buffer
366 assert_select "div.task_done[style*=width:16px]", 1
631 end
367 end
632
368
633 should "not be the total done width if the chart starts after issue start date" do
369 test "#line done line should be the total width for 100% done ratio" do
634 create_gantt(@project, :date_from => (today - 5))
370 create_gantt
635 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
371 @output_buffer = @gantt.line(today - 7, today + 7, 100, false, 'line', :format => :html, :zoom => 4)
636 assert_select "div.task_done[style*=left:0px]", true, @output_buffer
372 # 15 days * 4 px - 2 px for borders = 58 px
637 assert_select "div.task_done[style*=width:8px]", true, @output_buffer
373 assert_select "div.task_done[style*=width:58px]", 1
638 end
374 end
639
375
640 context "for completed issue" do
376 test "#line done line should be the total width for 100% done ratio with same start and end dates" do
641 setup do
377 create_gantt
642 @issue.done_ratio = 100
378 @output_buffer = @gantt.line(today + 7, today + 7, 100, false, 'line', :format => :html, :zoom => 4)
379 assert_select "div.task_done[style*=width:2px]", 1
643 end
380 end
644
381
645 should "be the total width of the issue" do
382 test "#line done line should not be the total done width if the gantt starts after start date" do
646 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
383 create_gantt
647 assert_select "div.task_done[style*=width:58px]", true, @output_buffer
384 @output_buffer = @gantt.line(today - 16, today - 2, 30, false, 'line', :format => :html, :zoom => 4)
385 assert_select "div.task_done[style*=left:0px]", 1
386 assert_select "div.task_done[style*=width:8px]", 1
648 end
387 end
649
388
650 should "be the total width of the issue with due_date=start_date" do
389 test "#line starting marker should appear at the start date" do
651 @issue.due_date = @issue.start_date
390 create_gantt
652 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
391 @output_buffer = @gantt.line(today - 7, today + 7, 30, true, 'line', :format => :html, :zoom => 4)
653 assert_select "div.task_done[style*=width:2px]", true, @output_buffer
392 assert_select "div.starting", 1
654 end
393 assert_select "div.starting[style*=left:28px]", 1
655 end
656 end
394 end
657
395
658 context "status content" do
396 test "#line starting marker should not appear if the start date is before gantt start date" do
659 should "appear at the far left, even if it's far in the past" do
397 create_gantt
660 @gantt.instance_variable_set('@date_to', (today - 14))
398 @output_buffer = @gantt.line(gantt_start - 2, today + 7, 30, true, 'line', :format => :html, :zoom => 4)
661 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
399 assert_select "div.starting", 0
662 assert_select "div.task.label", true, @output_buffer
663 end
400 end
664
401
665 should "show the issue status" do
402 test "#line ending marker should appear at the end date" do
666 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
403 create_gantt
667 assert_select "div.task.label", /#{@issue.status.name}/
404 @output_buffer = @gantt.line(today - 7, today + 7, 30, true, 'line', :format => :html, :zoom => 4)
405 assert_select "div.ending", 1
406 assert_select "div.ending[style*=left:88px]", 1
668 end
407 end
669
408
670 should "show the percent complete" do
409 test "#line ending marker should not appear if the end date is before gantt start date" do
671 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
410 create_gantt
672 assert_select "div.task.label", /30%/
411 @output_buffer = @gantt.line(gantt_start - 30, gantt_start - 21, 30, true, 'line', :format => :html)
673 end
412 assert_select "div.ending", 0
674 end
675 end
413 end
676
414
677 should "have an issue tooltip" do
415 test "#line label should appear at the far left, even if it's before gantt start date" do
678 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
416 create_gantt
679 assert_select "div.tooltip", /#{@issue.subject}/
417 @output_buffer = @gantt.line(gantt_start - 30, gantt_start - 21, 30, true, 'line', :format => :html)
680 end
418 assert_select "div.label", :text => 'line'
681 end
419 end
682
420
683 def test_sort_issues_no_date
421 def test_sort_issues_no_date
@@ -749,11 +487,12 class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
749
487
750 def test_sort_versions
488 def test_sort_versions
751 project = Project.generate!
489 project = Project.generate!
752 version1 = Version.create!(:project => project, :name => 'test1')
490 versions = []
753 version2 = Version.create!(:project => project, :name => 'test2', :effective_date => '2013-10-25')
491 versions << Version.create!(:project => project, :name => 'test1')
754 version3 = Version.create!(:project => project, :name => 'test3')
492 versions << Version.create!(:project => project, :name => 'test2', :effective_date => '2013-10-25')
755 version4 = Version.create!(:project => project, :name => 'test4', :effective_date => '2013-10-02')
493 versions << Version.create!(:project => project, :name => 'test3')
494 versions << Version.create!(:project => project, :name => 'test4', :effective_date => '2013-10-02')
756
495
757 assert_equal versions.sort, Redmine::Helpers::Gantt.sort_versions!(versions)
496 assert_equal versions.sort, Redmine::Helpers::Gantt.sort_versions!(versions.dup)
758 end
497 end
759 end
498 end
General Comments 0
You need to be logged in to leave comments. Login now