##// END OF EJS Templates
add fixtures to test/unit/lib/redmine/helpers/gantt_test.rb...
Toshi MARUYAMA -
r9358:d19a7dee42b9
parent child
Show More
@@ -1,754 +1,766
1 1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2012 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
20 20 class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
21 fixtures :projects, :trackers, :issue_statuses, :issues,
22 :journals, :journal_details,
23 :enumerations, :users, :issue_categories,
24 :projects_trackers,
25 :roles,
26 :member_roles,
27 :members,
28 :enabled_modules,
29 :workflows,
30 :versions,
31 :groups_users
32
21 33 include ApplicationHelper
22 34 include ProjectsHelper
23 35 include IssuesHelper
24 36 include ERB::Util
25 37
26 38 def setup
27 39 setup_with_controller
28 40 User.current = User.find(1)
29 41 end
30 42
31 43 # Creates a Gantt chart for a 4 week span
32 44 def create_gantt(project=Project.generate!, options={})
33 45 @project = project
34 46 @gantt = Redmine::Helpers::Gantt.new(options)
35 47 @gantt.project = @project
36 48 @gantt.query = Query.create!(:project => @project, :name => 'Gantt')
37 49 @gantt.view = self
38 50 @gantt.instance_variable_set('@date_from', options[:date_from] || 2.weeks.ago.to_date)
39 51 @gantt.instance_variable_set('@date_to', options[:date_to] || 2.weeks.from_now.to_date)
40 52 end
41 53
42 54 context "#number_of_rows" do
43 55
44 56 context "with one project" do
45 57 should "return the number of rows just for that project"
46 58 end
47 59
48 60 context "with no project" do
49 61 should "return the total number of rows for all the projects, resursively"
50 62 end
51 63
52 64 should "not exceed max_rows option" do
53 65 p = Project.generate!
54 66 5.times do
55 67 Issue.generate_for_project!(p)
56 68 end
57 69
58 70 create_gantt(p)
59 71 @gantt.render
60 72 assert_equal 6, @gantt.number_of_rows
61 73 assert !@gantt.truncated
62 74
63 75 create_gantt(p, :max_rows => 3)
64 76 @gantt.render
65 77 assert_equal 3, @gantt.number_of_rows
66 78 assert @gantt.truncated
67 79 end
68 80 end
69 81
70 82 context "#number_of_rows_on_project" do
71 83 setup do
72 84 create_gantt
73 85 end
74 86
75 87 should "count 0 for an empty the project" do
76 88 assert_equal 0, @gantt.number_of_rows_on_project(@project)
77 89 end
78 90
79 91 should "count the number of issues without a version" do
80 92 @project.issues << Issue.generate_for_project!(@project, :fixed_version => nil)
81 93 assert_equal 2, @gantt.number_of_rows_on_project(@project)
82 94 end
83 95
84 96 should "count the number of issues on versions, including cross-project" do
85 97 version = Version.generate!
86 98 @project.versions << version
87 99 @project.issues << Issue.generate_for_project!(@project, :fixed_version => version)
88 100
89 101 assert_equal 3, @gantt.number_of_rows_on_project(@project)
90 102 end
91 103 end
92 104
93 105 # TODO: more of an integration test
94 106 context "#subjects" do
95 107 setup do
96 108 create_gantt
97 109 @project.enabled_module_names = [:issue_tracking]
98 110 @tracker = Tracker.generate!
99 111 @project.trackers << @tracker
100 112 @version = Version.generate!(:effective_date => 1.week.from_now.to_date, :sharing => 'none')
101 113 @project.versions << @version
102 114
103 115 @issue = Issue.generate!(:fixed_version => @version,
104 116 :subject => "gantt#line_for_project",
105 117 :tracker => @tracker,
106 118 :project => @project,
107 119 :done_ratio => 30,
108 120 :start_date => Date.yesterday,
109 121 :due_date => 1.week.from_now.to_date)
110 122 @project.issues << @issue
111 123 end
112 124
113 125 context "project" do
114 126 should "be rendered" do
115 127 @output_buffer = @gantt.subjects
116 128 assert_select "div.project-name a", /#{@project.name}/
117 129 end
118 130
119 131 should "have an indent of 4" do
120 132 @output_buffer = @gantt.subjects
121 133 assert_select "div.project-name[style*=left:4px]"
122 134 end
123 135 end
124 136
125 137 context "version" do
126 138 should "be rendered" do
127 139 @output_buffer = @gantt.subjects
128 140 assert_select "div.version-name a", /#{@version.name}/
129 141 end
130 142
131 143 should "be indented 24 (one level)" do
132 144 @output_buffer = @gantt.subjects
133 145 assert_select "div.version-name[style*=left:24px]"
134 146 end
135 147
136 148 context "without assigned issues" do
137 149 setup do
138 150 @version = Version.generate!(:effective_date => 2.week.from_now.to_date, :sharing => 'none', :name => 'empty_version')
139 151 @project.versions << @version
140 152 end
141 153
142 154 should "not be rendered" do
143 155 @output_buffer = @gantt.subjects
144 156 assert_select "div.version-name a", :text => /#{@version.name}/, :count => 0
145 157 end
146 158 end
147 159 end
148 160
149 161 context "issue" do
150 162 should "be rendered" do
151 163 @output_buffer = @gantt.subjects
152 164 assert_select "div.issue-subject", /#{@issue.subject}/
153 165 end
154 166
155 167 should "be indented 44 (two levels)" do
156 168 @output_buffer = @gantt.subjects
157 169 assert_select "div.issue-subject[style*=left:44px]"
158 170 end
159 171
160 172 context "assigned to a shared version of another project" do
161 173 setup do
162 174 p = Project.generate!
163 175 p.enabled_module_names = [:issue_tracking]
164 176 @shared_version = Version.generate!(:sharing => 'system')
165 177 p.versions << @shared_version
166 178 # Reassign the issue to a shared version of another project
167 179
168 180 @issue = Issue.generate!(:fixed_version => @shared_version,
169 181 :subject => "gantt#assigned_to_shared_version",
170 182 :tracker => @tracker,
171 183 :project => @project,
172 184 :done_ratio => 30,
173 185 :start_date => Date.yesterday,
174 186 :due_date => 1.week.from_now.to_date)
175 187 @project.issues << @issue
176 188 end
177 189
178 190 should "be rendered" do
179 191 @output_buffer = @gantt.subjects
180 192 assert_select "div.issue-subject", /#{@issue.subject}/
181 193 end
182 194 end
183 195
184 196 context "with subtasks" do
185 197 setup do
186 198 attrs = {:project => @project, :tracker => @tracker, :fixed_version => @version}
187 199 @child1 = Issue.generate!(attrs.merge(:subject => 'child1', :parent_issue_id => @issue.id, :start_date => Date.yesterday, :due_date => 2.day.from_now.to_date))
188 200 @child2 = Issue.generate!(attrs.merge(:subject => 'child2', :parent_issue_id => @issue.id, :start_date => Date.today, :due_date => 1.week.from_now.to_date))
189 201 @grandchild = Issue.generate!(attrs.merge(:subject => 'grandchild', :parent_issue_id => @child1.id, :start_date => Date.yesterday, :due_date => 2.day.from_now.to_date))
190 202 end
191 203
192 204 should "indent subtasks" do
193 205 @output_buffer = @gantt.subjects
194 206 # parent task 44px
195 207 assert_select "div.issue-subject[style*=left:44px]", /#{@issue.subject}/
196 208 # children 64px
197 209 assert_select "div.issue-subject[style*=left:64px]", /child1/
198 210 assert_select "div.issue-subject[style*=left:64px]", /child2/
199 211 # grandchild 84px
200 212 assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @output_buffer
201 213 end
202 214 end
203 215 end
204 216 end
205 217
206 218 context "#lines" do
207 219 setup do
208 220 create_gantt
209 221 @project.enabled_module_names = [:issue_tracking]
210 222 @tracker = Tracker.generate!
211 223 @project.trackers << @tracker
212 224 @version = Version.generate!(:effective_date => 1.week.from_now.to_date)
213 225 @project.versions << @version
214 226 @issue = Issue.generate!(:fixed_version => @version,
215 227 :subject => "gantt#line_for_project",
216 228 :tracker => @tracker,
217 229 :project => @project,
218 230 :done_ratio => 30,
219 231 :start_date => Date.yesterday,
220 232 :due_date => 1.week.from_now.to_date)
221 233 @project.issues << @issue
222 234
223 235 @output_buffer = @gantt.lines
224 236 end
225 237
226 238 context "project" do
227 239 should "be rendered" do
228 240 assert_select "div.project.task_todo"
229 241 assert_select "div.project.starting"
230 242 assert_select "div.project.ending"
231 243 assert_select "div.label.project", /#{@project.name}/
232 244 end
233 245 end
234 246
235 247 context "version" do
236 248 should "be rendered" do
237 249 assert_select "div.version.task_todo"
238 250 assert_select "div.version.starting"
239 251 assert_select "div.version.ending"
240 252 assert_select "div.label.version", /#{@version.name}/
241 253 end
242 254 end
243 255
244 256 context "issue" do
245 257 should "be rendered" do
246 258 assert_select "div.task_todo"
247 259 assert_select "div.task.label", /#{@issue.done_ratio}/
248 260 assert_select "div.tooltip", /#{@issue.subject}/
249 261 end
250 262 end
251 263 end
252 264
253 265 context "#render_project" do
254 266 should "be tested"
255 267 end
256 268
257 269 context "#render_issues" do
258 270 should "be tested"
259 271 end
260 272
261 273 context "#render_version" do
262 274 should "be tested"
263 275 end
264 276
265 277 context "#subject_for_project" do
266 278 setup do
267 279 create_gantt
268 280 end
269 281
270 282 context ":html format" do
271 283 should "add an absolute positioned div" do
272 284 @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
273 285 assert_select "div[style*=absolute]"
274 286 end
275 287
276 288 should "use the indent option to move the div to the right" do
277 289 @output_buffer = @gantt.subject_for_project(@project, {:format => :html, :indent => 40})
278 290 assert_select "div[style*=left:40]"
279 291 end
280 292
281 293 should "include the project name" do
282 294 @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
283 295 assert_select 'div', :text => /#{@project.name}/
284 296 end
285 297
286 298 should "include a link to the project" do
287 299 @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
288 300 assert_select 'a[href=?]', "/projects/#{@project.identifier}", :text => /#{@project.name}/
289 301 end
290 302
291 303 should "style overdue projects" do
292 304 @project.enabled_module_names = [:issue_tracking]
293 305 @project.versions << Version.generate!(:effective_date => Date.yesterday)
294 306
295 307 assert @project.reload.overdue?, "Need an overdue project for this test"
296 308 @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
297 309
298 310 assert_select 'div span.project-overdue'
299 311 end
300 312
301 313
302 314 end
303 315
304 316 should "test the PNG format"
305 317 should "test the PDF format"
306 318 end
307 319
308 320 context "#line_for_project" do
309 321 setup do
310 322 create_gantt
311 323 @project.enabled_module_names = [:issue_tracking]
312 324 @tracker = Tracker.generate!
313 325 @project.trackers << @tracker
314 326 @version = Version.generate!(:effective_date => Date.yesterday)
315 327 @project.versions << @version
316 328
317 329 @project.issues << Issue.generate!(:fixed_version => @version,
318 330 :subject => "gantt#line_for_project",
319 331 :tracker => @tracker,
320 332 :project => @project,
321 333 :done_ratio => 30,
322 334 :start_date => 1.week.ago.to_date,
323 335 :due_date => 1.week.from_now.to_date)
324 336 end
325 337
326 338 context ":html format" do
327 339 context "todo line" do
328 340 should "start from the starting point on the left" do
329 341 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
330 342 assert_select "div.project.task_todo[style*=left:28px]", true, @output_buffer
331 343 end
332 344
333 345 should "be the total width of the project" do
334 346 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
335 347 assert_select "div.project.task_todo[style*=width:58px]", true, @output_buffer
336 348 end
337 349
338 350 end
339 351
340 352 context "late line" do
341 353 should_eventually "start from the starting point on the left" do
342 354 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
343 355 assert_select "div.project.task_late[style*=left:28px]", true, @output_buffer
344 356 end
345 357
346 358 should_eventually "be the total delayed width of the project" do
347 359 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
348 360 assert_select "div.project.task_late[style*=width:30px]", true, @output_buffer
349 361 end
350 362 end
351 363
352 364 context "done line" do
353 365 should_eventually "start from the starting point on the left" do
354 366 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
355 367 assert_select "div.project.task_done[style*=left:28px]", true, @output_buffer
356 368 end
357 369
358 370 should_eventually "Be the total done width of the project" do
359 371 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
360 372 assert_select "div.project.task_done[style*=width:18px]", true, @output_buffer
361 373 end
362 374 end
363 375
364 376 context "starting marker" do
365 377 should "not appear if the starting point is off the gantt chart" do
366 378 # Shift the date range of the chart
367 379 @gantt.instance_variable_set('@date_from', Date.today)
368 380
369 381 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
370 382 assert_select "div.project.starting", false, @output_buffer
371 383 end
372 384
373 385 should "appear at the starting point" do
374 386 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
375 387 assert_select "div.project.starting[style*=left:28px]", true, @output_buffer
376 388 end
377 389 end
378 390
379 391 context "ending marker" do
380 392 should "not appear if the starting point is off the gantt chart" do
381 393 # Shift the date range of the chart
382 394 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
383 395
384 396 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
385 397 assert_select "div.project.ending", false, @output_buffer
386 398
387 399 end
388 400
389 401 should "appear at the end of the date range" do
390 402 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
391 403 assert_select "div.project.ending[style*=left:88px]", true, @output_buffer
392 404 end
393 405 end
394 406
395 407 context "status content" do
396 408 should "appear at the far left, even if it's far in the past" do
397 409 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
398 410
399 411 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
400 412 assert_select "div.project.label", /#{@project.name}/
401 413 end
402 414
403 415 should "show the project name" do
404 416 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
405 417 assert_select "div.project.label", /#{@project.name}/
406 418 end
407 419
408 420 should_eventually "show the percent complete" do
409 421 @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
410 422 assert_select "div.project.label", /0%/
411 423 end
412 424 end
413 425 end
414 426
415 427 should "test the PNG format"
416 428 should "test the PDF format"
417 429 end
418 430
419 431 context "#subject_for_version" do
420 432 setup do
421 433 create_gantt
422 434 @project.enabled_module_names = [:issue_tracking]
423 435 @tracker = Tracker.generate!
424 436 @project.trackers << @tracker
425 437 @version = Version.generate!(:effective_date => Date.yesterday)
426 438 @project.versions << @version
427 439
428 440 @project.issues << Issue.generate!(:fixed_version => @version,
429 441 :subject => "gantt#subject_for_version",
430 442 :tracker => @tracker,
431 443 :project => @project,
432 444 :start_date => Date.today)
433 445
434 446 end
435 447
436 448 context ":html format" do
437 449 should "add an absolute positioned div" do
438 450 @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
439 451 assert_select "div[style*=absolute]"
440 452 end
441 453
442 454 should "use the indent option to move the div to the right" do
443 455 @output_buffer = @gantt.subject_for_version(@version, {:format => :html, :indent => 40})
444 456 assert_select "div[style*=left:40]"
445 457 end
446 458
447 459 should "include the version name" do
448 460 @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
449 461 assert_select 'div', :text => /#{@version.name}/
450 462 end
451 463
452 464 should "include a link to the version" do
453 465 @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
454 466 assert_select 'a[href=?]', Regexp.escape("/versions/#{@version.to_param}"), :text => /#{@version.name}/
455 467 end
456 468
457 469 should "style late versions" do
458 470 assert @version.overdue?, "Need an overdue version for this test"
459 471 @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
460 472
461 473 assert_select 'div span.version-behind-schedule'
462 474 end
463 475
464 476 should "style behind schedule versions" do
465 477 assert @version.behind_schedule?, "Need a behind schedule version for this test"
466 478 @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
467 479
468 480 assert_select 'div span.version-behind-schedule'
469 481 end
470 482 end
471 483 should "test the PNG format"
472 484 should "test the PDF format"
473 485 end
474 486
475 487 context "#line_for_version" do
476 488 setup do
477 489 create_gantt
478 490 @project.enabled_module_names = [:issue_tracking]
479 491 @tracker = Tracker.generate!
480 492 @project.trackers << @tracker
481 493 @version = Version.generate!(:effective_date => 1.week.from_now.to_date)
482 494 @project.versions << @version
483 495
484 496 @project.issues << Issue.generate!(:fixed_version => @version,
485 497 :subject => "gantt#line_for_project",
486 498 :tracker => @tracker,
487 499 :project => @project,
488 500 :done_ratio => 30,
489 501 :start_date => 1.week.ago.to_date,
490 502 :due_date => 1.week.from_now.to_date)
491 503 end
492 504
493 505 context ":html format" do
494 506 context "todo line" do
495 507 should "start from the starting point on the left" do
496 508 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
497 509 assert_select "div.version.task_todo[style*=left:28px]", true, @output_buffer
498 510 end
499 511
500 512 should "be the total width of the version" do
501 513 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
502 514 assert_select "div.version.task_todo[style*=width:58px]", true, @output_buffer
503 515 end
504 516
505 517 end
506 518
507 519 context "late line" do
508 520 should "start from the starting point on the left" do
509 521 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
510 522 assert_select "div.version.task_late[style*=left:28px]", true, @output_buffer
511 523 end
512 524
513 525 should "be the total delayed width of the version" do
514 526 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
515 527 assert_select "div.version.task_late[style*=width:30px]", true, @output_buffer
516 528 end
517 529 end
518 530
519 531 context "done line" do
520 532 should "start from the starting point on the left" do
521 533 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
522 534 assert_select "div.version.task_done[style*=left:28px]", true, @output_buffer
523 535 end
524 536
525 537 should "be the total done width of the version" do
526 538 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
527 539 assert_select "div.version.task_done[style*=width:16px]", true, @output_buffer
528 540 end
529 541 end
530 542
531 543 context "starting marker" do
532 544 should "not appear if the starting point is off the gantt chart" do
533 545 # Shift the date range of the chart
534 546 @gantt.instance_variable_set('@date_from', Date.today)
535 547
536 548 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
537 549 assert_select "div.version.starting", false
538 550 end
539 551
540 552 should "appear at the starting point" do
541 553 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
542 554 assert_select "div.version.starting[style*=left:28px]", true, @output_buffer
543 555 end
544 556 end
545 557
546 558 context "ending marker" do
547 559 should "not appear if the starting point is off the gantt chart" do
548 560 # Shift the date range of the chart
549 561 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
550 562
551 563 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
552 564 assert_select "div.version.ending", false
553 565
554 566 end
555 567
556 568 should "appear at the end of the date range" do
557 569 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
558 570 assert_select "div.version.ending[style*=left:88px]", true, @output_buffer
559 571 end
560 572 end
561 573
562 574 context "status content" do
563 575 should "appear at the far left, even if it's far in the past" do
564 576 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
565 577
566 578 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
567 579 assert_select "div.version.label", /#{@version.name}/
568 580 end
569 581
570 582 should "show the version name" do
571 583 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
572 584 assert_select "div.version.label", /#{@version.name}/
573 585 end
574 586
575 587 should "show the percent complete" do
576 588 @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
577 589 assert_select "div.version.label", /30%/
578 590 end
579 591 end
580 592 end
581 593
582 594 should "test the PNG format"
583 595 should "test the PDF format"
584 596 end
585 597
586 598 context "#subject_for_issue" do
587 599 setup do
588 600 create_gantt
589 601 @project.enabled_module_names = [:issue_tracking]
590 602 @tracker = Tracker.generate!
591 603 @project.trackers << @tracker
592 604
593 605 @issue = Issue.generate!(:subject => "gantt#subject_for_issue",
594 606 :tracker => @tracker,
595 607 :project => @project,
596 608 :start_date => 3.days.ago.to_date,
597 609 :due_date => Date.yesterday)
598 610 @project.issues << @issue
599 611
600 612 end
601 613
602 614 context ":html format" do
603 615 should "add an absolute positioned div" do
604 616 @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
605 617 assert_select "div[style*=absolute]"
606 618 end
607 619
608 620 should "use the indent option to move the div to the right" do
609 621 @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html, :indent => 40})
610 622 assert_select "div[style*=left:40]"
611 623 end
612 624
613 625 should "include the issue subject" do
614 626 @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
615 627 assert_select 'div', :text => /#{@issue.subject}/
616 628 end
617 629
618 630 should "include a link to the issue" do
619 631 @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
620 632 assert_select 'a[href=?]', Regexp.escape("/issues/#{@issue.to_param}"), :text => /#{@tracker.name} ##{@issue.id}/
621 633 end
622 634
623 635 should "style overdue issues" do
624 636 assert @issue.overdue?, "Need an overdue issue for this test"
625 637 @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
626 638
627 639 assert_select 'div span.issue-overdue'
628 640 end
629 641
630 642 end
631 643 should "test the PNG format"
632 644 should "test the PDF format"
633 645 end
634 646
635 647 context "#line_for_issue" do
636 648 setup do
637 649 create_gantt
638 650 @project.enabled_module_names = [:issue_tracking]
639 651 @tracker = Tracker.generate!
640 652 @project.trackers << @tracker
641 653 @version = Version.generate!(:effective_date => 1.week.from_now.to_date)
642 654 @project.versions << @version
643 655 @issue = Issue.generate!(:fixed_version => @version,
644 656 :subject => "gantt#line_for_project",
645 657 :tracker => @tracker,
646 658 :project => @project,
647 659 :done_ratio => 30,
648 660 :start_date => 1.week.ago.to_date,
649 661 :due_date => 1.week.from_now.to_date)
650 662 @project.issues << @issue
651 663 end
652 664
653 665 context ":html format" do
654 666 context "todo line" do
655 667 should "start from the starting point on the left" do
656 668 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
657 669 assert_select "div.task_todo[style*=left:28px]", true, @output_buffer
658 670 end
659 671
660 672 should "be the total width of the issue" do
661 673 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
662 674 assert_select "div.task_todo[style*=width:58px]", true, @output_buffer
663 675 end
664 676
665 677 end
666 678
667 679 context "late line" do
668 680 should "start from the starting point on the left" do
669 681 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
670 682 assert_select "div.task_late[style*=left:28px]", true, @output_buffer
671 683 end
672 684
673 685 should "be the total delayed width of the issue" do
674 686 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
675 687 assert_select "div.task_late[style*=width:30px]", true, @output_buffer
676 688 end
677 689 end
678 690
679 691 context "done line" do
680 692 should "start from the starting point on the left" do
681 693 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
682 694 assert_select "div.task_done[style*=left:28px]", true, @output_buffer
683 695 end
684 696
685 697 should "be the total done width of the issue" do
686 698 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
687 699 # 15 days * 4 px * 30% - 2 px for borders = 16 px
688 700 assert_select "div.task_done[style*=width:16px]", true, @output_buffer
689 701 end
690 702
691 703 should "not be the total done width if the chart starts after issue start date" do
692 704 create_gantt(@project, :date_from => 5.days.ago.to_date)
693 705
694 706 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
695 707 assert_select "div.task_done[style*=left:0px]", true, @output_buffer
696 708 assert_select "div.task_done[style*=width:8px]", true, @output_buffer
697 709 end
698 710
699 711 context "for completed issue" do
700 712 setup do
701 713 @issue.done_ratio = 100
702 714 end
703 715
704 716 should "be the total width of the issue" do
705 717 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
706 718 assert_select "div.task_done[style*=width:58px]", true, @output_buffer
707 719 end
708 720
709 721 should "be the total width of the issue with due_date=start_date" do
710 722 @issue.due_date = @issue.start_date
711 723 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
712 724 assert_select "div.task_done[style*=width:2px]", true, @output_buffer
713 725 end
714 726 end
715 727 end
716 728
717 729 context "status content" do
718 730 should "appear at the far left, even if it's far in the past" do
719 731 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
720 732
721 733 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
722 734 assert_select "div.task.label", true, @output_buffer
723 735 end
724 736
725 737 should "show the issue status" do
726 738 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
727 739 assert_select "div.task.label", /#{@issue.status.name}/
728 740 end
729 741
730 742 should "show the percent complete" do
731 743 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
732 744 assert_select "div.task.label", /30%/
733 745 end
734 746 end
735 747 end
736 748
737 749 should "have an issue tooltip" do
738 750 @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
739 751 assert_select "div.tooltip", /#{@issue.subject}/
740 752 end
741 753
742 754 should "test the PNG format"
743 755 should "test the PDF format"
744 756 end
745 757
746 758 context "#to_image" do
747 759 should "be tested"
748 760 end
749 761
750 762 context "#to_pdf" do
751 763 should "be tested"
752 764 end
753 765
754 766 end
General Comments 0
You need to be logged in to leave comments. Login now