Mercurial > hg > soundsoftware-site
comparison test/unit/lib/redmine/helpers/.svn/text-base/gantt_test.rb.svn-base @ 117:af80e5618e9b redmine-1.1
* Update to Redmine 1.1-stable branch (Redmine SVN rev 4707)
author | Chris Cannam |
---|---|
date | Thu, 13 Jan 2011 12:53:21 +0000 |
parents | 40f7cfd4df19 |
children | cbce1fd3b1b7 |
comparison
equal
deleted
inserted
replaced
39:150ceac17a8d | 117:af80e5618e9b |
---|---|
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require File.dirname(__FILE__) + '/../../../../test_helper' | 18 require File.expand_path('../../../../../test_helper', __FILE__) |
19 | 19 |
20 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | 20 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase |
21 # Utility methods and classes so assert_select can be used. | 21 # Utility methods and classes so assert_select can be used. |
22 class GanttViewTest < ActionView::Base | 22 class GanttViewTest < ActionView::Base |
23 include ActionView::Helpers::UrlHelper | 23 include ActionView::Helpers::UrlHelper |
51 def html_document | 51 def html_document |
52 HTML::Document.new(@response.body) | 52 HTML::Document.new(@response.body) |
53 end | 53 end |
54 | 54 |
55 # Creates a Gantt chart for a 4 week span | 55 # Creates a Gantt chart for a 4 week span |
56 def create_gantt(project=Project.generate!) | 56 def create_gantt(project=Project.generate!, options={}) |
57 @project = project | 57 @project = project |
58 @gantt = Redmine::Helpers::Gantt.new | 58 @gantt = Redmine::Helpers::Gantt.new(options) |
59 @gantt.project = @project | 59 @gantt.project = @project |
60 @gantt.query = Query.generate_default!(:project => @project) | 60 @gantt.query = Query.generate_default!(:project => @project) |
61 @gantt.view = build_view | 61 @gantt.view = build_view |
62 @gantt.instance_variable_set('@date_from', 2.weeks.ago.to_date) | 62 @gantt.instance_variable_set('@date_from', options[:date_from] || 2.weeks.ago.to_date) |
63 @gantt.instance_variable_set('@date_to', 2.weeks.from_now.to_date) | 63 @gantt.instance_variable_set('@date_to', options[:date_to] || 2.weeks.from_now.to_date) |
64 end | 64 end |
65 | 65 |
66 context "#number_of_rows" do | 66 context "#number_of_rows" do |
67 | 67 |
68 context "with one project" do | 68 context "with one project" do |
71 | 71 |
72 context "with no project" do | 72 context "with no project" do |
73 should "return the total number of rows for all the projects, resursively" | 73 should "return the total number of rows for all the projects, resursively" |
74 end | 74 end |
75 | 75 |
76 should "not exceed max_rows option" do | |
77 p = Project.generate! | |
78 5.times do | |
79 Issue.generate_for_project!(p) | |
80 end | |
81 | |
82 create_gantt(p) | |
83 @gantt.render | |
84 assert_equal 6, @gantt.number_of_rows | |
85 assert !@gantt.truncated | |
86 | |
87 create_gantt(p, :max_rows => 3) | |
88 @gantt.render | |
89 assert_equal 3, @gantt.number_of_rows | |
90 assert @gantt.truncated | |
91 end | |
76 end | 92 end |
77 | 93 |
78 context "#number_of_rows_on_project" do | 94 context "#number_of_rows_on_project" do |
79 setup do | 95 setup do |
80 create_gantt | 96 create_gantt |
140 :tracker => @tracker, | 156 :tracker => @tracker, |
141 :project => @project, | 157 :project => @project, |
142 :done_ratio => 30, | 158 :done_ratio => 30, |
143 :start_date => Date.yesterday, | 159 :start_date => Date.yesterday, |
144 :due_date => 1.week.from_now.to_date) | 160 :due_date => 1.week.from_now.to_date) |
145 @project.issues << @issue | 161 @project.issues << @issue |
146 | 162 end |
147 @response.body = @gantt.subjects | 163 |
148 end | |
149 | |
150 context "project" do | 164 context "project" do |
151 should "be rendered" do | 165 should "be rendered" do |
166 @response.body = @gantt.subjects | |
152 assert_select "div.project-name a", /#{@project.name}/ | 167 assert_select "div.project-name a", /#{@project.name}/ |
153 end | 168 end |
154 | 169 |
155 should "have an indent of 4" do | 170 should "have an indent of 4" do |
171 @response.body = @gantt.subjects | |
156 assert_select "div.project-name[style*=left:4px]" | 172 assert_select "div.project-name[style*=left:4px]" |
157 end | 173 end |
158 end | 174 end |
159 | 175 |
160 context "version" do | 176 context "version" do |
161 should "be rendered" do | 177 should "be rendered" do |
178 @response.body = @gantt.subjects | |
162 assert_select "div.version-name a", /#{@version.name}/ | 179 assert_select "div.version-name a", /#{@version.name}/ |
163 end | 180 end |
164 | 181 |
165 should "be indented 24 (one level)" do | 182 should "be indented 24 (one level)" do |
183 @response.body = @gantt.subjects | |
166 assert_select "div.version-name[style*=left:24px]" | 184 assert_select "div.version-name[style*=left:24px]" |
167 end | 185 end |
168 end | 186 end |
169 | 187 |
170 context "issue" do | 188 context "issue" do |
171 should "be rendered" do | 189 should "be rendered" do |
190 @response.body = @gantt.subjects | |
172 assert_select "div.issue-subject", /#{@issue.subject}/ | 191 assert_select "div.issue-subject", /#{@issue.subject}/ |
173 end | 192 end |
174 | 193 |
175 should "be indented 44 (two levels)" do | 194 should "be indented 44 (two levels)" do |
195 @response.body = @gantt.subjects | |
176 assert_select "div.issue-subject[style*=left:44px]" | 196 assert_select "div.issue-subject[style*=left:44px]" |
197 end | |
198 | |
199 context "with subtasks" do | |
200 setup do | |
201 attrs = {:project => @project, :tracker => @tracker, :fixed_version => @version} | |
202 @child1 = Issue.generate!(attrs.merge(:subject => 'child1', :parent_issue_id => @issue.id, :start_date => Date.yesterday, :due_date => 2.day.from_now.to_date)) | |
203 @child2 = Issue.generate!(attrs.merge(:subject => 'child2', :parent_issue_id => @issue.id, :start_date => Date.today, :due_date => 1.week.from_now.to_date)) | |
204 @grandchild = Issue.generate!(attrs.merge(:subject => 'grandchild', :parent_issue_id => @child1.id, :start_date => Date.yesterday, :due_date => 2.day.from_now.to_date)) | |
205 end | |
206 | |
207 should "indent subtasks" do | |
208 @response.body = @gantt.subjects | |
209 # parent task 44px | |
210 assert_select "div.issue-subject[style*=left:44px]", /#{@issue.subject}/ | |
211 # children 64px | |
212 assert_select "div.issue-subject[style*=left:64px]", /child1/ | |
213 assert_select "div.issue-subject[style*=left:64px]", /child2/ | |
214 # grandchild 84px | |
215 assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @response.body | |
216 end | |
177 end | 217 end |
178 end | 218 end |
179 end | 219 end |
180 | 220 |
181 context "#lines" do | 221 context "#lines" do |
198 @response.body = @gantt.lines | 238 @response.body = @gantt.lines |
199 end | 239 end |
200 | 240 |
201 context "project" do | 241 context "project" do |
202 should "be rendered" do | 242 should "be rendered" do |
203 assert_select "div.project_todo" | 243 assert_select "div.project.task_todo" |
204 assert_select "div.project-line.starting" | 244 assert_select "div.project.starting" |
205 assert_select "div.project-line.ending" | 245 assert_select "div.project.ending" |
206 assert_select "div.label.project-name", /#{@project.name}/ | 246 assert_select "div.label.project", /#{@project.name}/ |
207 end | 247 end |
208 end | 248 end |
209 | 249 |
210 context "version" do | 250 context "version" do |
211 should "be rendered" do | 251 should "be rendered" do |
212 assert_select "div.milestone_todo" | 252 assert_select "div.version.task_todo" |
213 assert_select "div.milestone.starting" | 253 assert_select "div.version.starting" |
214 assert_select "div.milestone.ending" | 254 assert_select "div.version.ending" |
215 assert_select "div.label.version-name", /#{@version.name}/ | 255 assert_select "div.label.version", /#{@version.name}/ |
216 end | 256 end |
217 end | 257 end |
218 | 258 |
219 context "issue" do | 259 context "issue" do |
220 should "be rendered" do | 260 should "be rendered" do |
221 assert_select "div.task_todo" | 261 assert_select "div.task_todo" |
222 assert_select "div.label.issue-name", /#{@issue.done_ratio}/ | 262 assert_select "div.task.label", /#{@issue.done_ratio}/ |
223 assert_select "div.tooltip", /#{@issue.subject}/ | 263 assert_select "div.tooltip", /#{@issue.subject}/ |
224 end | 264 end |
225 end | 265 end |
226 end | 266 end |
227 | 267 |
292 @project.issues << Issue.generate!(:fixed_version => @version, | 332 @project.issues << Issue.generate!(:fixed_version => @version, |
293 :subject => "gantt#line_for_project", | 333 :subject => "gantt#line_for_project", |
294 :tracker => @tracker, | 334 :tracker => @tracker, |
295 :project => @project, | 335 :project => @project, |
296 :done_ratio => 30, | 336 :done_ratio => 30, |
297 :start_date => Date.yesterday, | 337 :start_date => 1.week.ago.to_date, |
298 :due_date => 1.week.from_now.to_date) | 338 :due_date => 1.week.from_now.to_date) |
299 end | 339 end |
300 | 340 |
301 context ":html format" do | 341 context ":html format" do |
302 context "todo line" do | 342 context "todo line" do |
303 should "start from the starting point on the left" do | 343 should "start from the starting point on the left" do |
304 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 344 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
305 assert_select "div.project_todo[style*=left:52px]" | 345 assert_select "div.project.task_todo[style*=left:28px]", true, @response.body |
306 end | 346 end |
307 | 347 |
308 should "be the total width of the project" do | 348 should "be the total width of the project" do |
309 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 349 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
310 assert_select "div.project_todo[style*=width:31px]" | 350 assert_select "div.project.task_todo[style*=width:58px]", true, @response.body |
311 end | 351 end |
312 | 352 |
313 end | 353 end |
314 | 354 |
315 context "late line" do | 355 context "late line" do |
316 should "start from the starting point on the left" do | 356 should_eventually "start from the starting point on the left" do |
317 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 357 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
318 assert_select "div.project_late[style*=left:52px]" | 358 assert_select "div.project.task_late[style*=left:28px]", true, @response.body |
319 end | 359 end |
320 | 360 |
321 should "be the total delayed width of the project" do | 361 should_eventually "be the total delayed width of the project" do |
322 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 362 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
323 assert_select "div.project_late[style*=width:6px]" | 363 assert_select "div.project.task_late[style*=width:30px]", true, @response.body |
324 end | 364 end |
325 end | 365 end |
326 | 366 |
327 context "done line" do | 367 context "done line" do |
328 should "start from the starting point on the left" do | 368 should_eventually "start from the starting point on the left" do |
329 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 369 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
330 assert_select "div.project_done[style*=left:52px]" | 370 assert_select "div.project.task_done[style*=left:28px]", true, @response.body |
331 end | 371 end |
332 | 372 |
333 should "Be the total done width of the project" do | 373 should_eventually "Be the total done width of the project" do |
334 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 374 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
335 assert_select "div.project_done[style*=left:52px]" | 375 assert_select "div.project.task_done[style*=width:18px]", true, @response.body |
336 end | 376 end |
337 end | 377 end |
338 | 378 |
339 context "starting marker" do | 379 context "starting marker" do |
340 should "not appear if the starting point is off the gantt chart" do | 380 should "not appear if the starting point is off the gantt chart" do |
341 # Shift the date range of the chart | 381 # Shift the date range of the chart |
342 @gantt.instance_variable_set('@date_from', Date.today) | 382 @gantt.instance_variable_set('@date_from', Date.today) |
343 | 383 |
344 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 384 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
345 assert_select "div.project-line.starting", false | 385 assert_select "div.project.starting", false, @response.body |
346 end | 386 end |
347 | 387 |
348 should "appear at the starting point" do | 388 should "appear at the starting point" do |
349 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 389 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
350 assert_select "div.project-line.starting[style*=left:52px]" | 390 assert_select "div.project.starting[style*=left:28px]", true, @response.body |
351 end | 391 end |
352 end | 392 end |
353 | 393 |
354 context "ending marker" do | 394 context "ending marker" do |
355 should "not appear if the starting point is off the gantt chart" do | 395 should "not appear if the starting point is off the gantt chart" do |
356 # Shift the date range of the chart | 396 # Shift the date range of the chart |
357 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) | 397 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
358 | 398 |
359 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 399 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
360 assert_select "div.project-line.ending", false | 400 assert_select "div.project.ending", false, @response.body |
361 | 401 |
362 end | 402 end |
363 | 403 |
364 should "appear at the end of the date range" do | 404 should "appear at the end of the date range" do |
365 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 405 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
366 assert_select "div.project-line.ending[style*=left:84px]" | 406 assert_select "div.project.ending[style*=left:88px]", true, @response.body |
367 end | 407 end |
368 end | 408 end |
369 | 409 |
370 context "status content" do | 410 context "status content" do |
371 should "appear at the far left, even if it's far in the past" do | 411 should "appear at the far left, even if it's far in the past" do |
372 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) | 412 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
373 | 413 |
374 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 414 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
375 assert_select "div.project-name", /#{@project.name}/ | 415 assert_select "div.project.label", /#{@project.name}/ |
376 end | 416 end |
377 | 417 |
378 should "show the project name" do | 418 should "show the project name" do |
379 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 419 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
380 assert_select "div.project-name", /#{@project.name}/ | 420 assert_select "div.project.label", /#{@project.name}/ |
381 end | 421 end |
382 | 422 |
383 should "show the percent complete" do | 423 should_eventually "show the percent complete" do |
384 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | 424 @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
385 assert_select "div.project-name", /0%/ | 425 assert_select "div.project.label", /0%/ |
386 end | 426 end |
387 end | 427 end |
388 end | 428 end |
389 | 429 |
390 should "test the PNG format" | 430 should "test the PNG format" |
459 @project.issues << Issue.generate!(:fixed_version => @version, | 499 @project.issues << Issue.generate!(:fixed_version => @version, |
460 :subject => "gantt#line_for_project", | 500 :subject => "gantt#line_for_project", |
461 :tracker => @tracker, | 501 :tracker => @tracker, |
462 :project => @project, | 502 :project => @project, |
463 :done_ratio => 30, | 503 :done_ratio => 30, |
464 :start_date => Date.yesterday, | 504 :start_date => 1.week.ago.to_date, |
465 :due_date => 1.week.from_now.to_date) | 505 :due_date => 1.week.from_now.to_date) |
466 end | 506 end |
467 | 507 |
468 context ":html format" do | 508 context ":html format" do |
469 context "todo line" do | 509 context "todo line" do |
470 should "start from the starting point on the left" do | 510 should "start from the starting point on the left" do |
471 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 511 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
472 assert_select "div.milestone_todo[style*=left:52px]" | 512 assert_select "div.version.task_todo[style*=left:28px]", true, @response.body |
473 end | 513 end |
474 | 514 |
475 should "be the total width of the version" do | 515 should "be the total width of the version" do |
476 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 516 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
477 assert_select "div.milestone_todo[style*=width:31px]" | 517 assert_select "div.version.task_todo[style*=width:58px]", true, @response.body |
478 end | 518 end |
479 | 519 |
480 end | 520 end |
481 | 521 |
482 context "late line" do | 522 context "late line" do |
483 should "start from the starting point on the left" do | 523 should "start from the starting point on the left" do |
484 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 524 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
485 assert_select "div.milestone_late[style*=left:52px]" | 525 assert_select "div.version.task_late[style*=left:28px]", true, @response.body |
486 end | 526 end |
487 | 527 |
488 should "be the total delayed width of the version" do | 528 should "be the total delayed width of the version" do |
489 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 529 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
490 assert_select "div.milestone_late[style*=width:6px]" | 530 assert_select "div.version.task_late[style*=width:30px]", true, @response.body |
491 end | 531 end |
492 end | 532 end |
493 | 533 |
494 context "done line" do | 534 context "done line" do |
495 should "start from the starting point on the left" do | 535 should "start from the starting point on the left" do |
496 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 536 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
497 assert_select "div.milestone_done[style*=left:52px]" | 537 assert_select "div.version.task_done[style*=left:28px]", true, @response.body |
498 end | 538 end |
499 | 539 |
500 should "Be the total done width of the version" do | 540 should "Be the total done width of the version" do |
501 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 541 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
502 assert_select "div.milestone_done[style*=left:52px]" | 542 assert_select "div.version.task_done[style*=width:18px]", true, @response.body |
503 end | 543 end |
504 end | 544 end |
505 | 545 |
506 context "starting marker" do | 546 context "starting marker" do |
507 should "not appear if the starting point is off the gantt chart" do | 547 should "not appear if the starting point is off the gantt chart" do |
508 # Shift the date range of the chart | 548 # Shift the date range of the chart |
509 @gantt.instance_variable_set('@date_from', Date.today) | 549 @gantt.instance_variable_set('@date_from', Date.today) |
510 | 550 |
511 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 551 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
512 assert_select "div.milestone.starting", false | 552 assert_select "div.version.starting", false |
513 end | 553 end |
514 | 554 |
515 should "appear at the starting point" do | 555 should "appear at the starting point" do |
516 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 556 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
517 assert_select "div.milestone.starting[style*=left:52px]" | 557 assert_select "div.version.starting[style*=left:28px]", true, @response.body |
518 end | 558 end |
519 end | 559 end |
520 | 560 |
521 context "ending marker" do | 561 context "ending marker" do |
522 should "not appear if the starting point is off the gantt chart" do | 562 should "not appear if the starting point is off the gantt chart" do |
523 # Shift the date range of the chart | 563 # Shift the date range of the chart |
524 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) | 564 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
525 | 565 |
526 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 566 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
527 assert_select "div.milestone.ending", false | 567 assert_select "div.version.ending", false |
528 | 568 |
529 end | 569 end |
530 | 570 |
531 should "appear at the end of the date range" do | 571 should "appear at the end of the date range" do |
532 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 572 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
533 assert_select "div.milestone.ending[style*=left:84px]" | 573 assert_select "div.version.ending[style*=left:88px]", true, @response.body |
534 end | 574 end |
535 end | 575 end |
536 | 576 |
537 context "status content" do | 577 context "status content" do |
538 should "appear at the far left, even if it's far in the past" do | 578 should "appear at the far left, even if it's far in the past" do |
539 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) | 579 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
540 | 580 |
541 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 581 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
542 assert_select "div.version-name", /#{@version.name}/ | 582 assert_select "div.version.label", /#{@version.name}/ |
543 end | 583 end |
544 | 584 |
545 should "show the version name" do | 585 should "show the version name" do |
546 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 586 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
547 assert_select "div.version-name", /#{@version.name}/ | 587 assert_select "div.version.label", /#{@version.name}/ |
548 end | 588 end |
549 | 589 |
550 should "show the percent complete" do | 590 should "show the percent complete" do |
551 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | 591 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) |
552 assert_select "div.version-name", /30%/ | 592 assert_select "div.version.label", /30%/ |
553 end | 593 end |
554 end | 594 end |
555 end | 595 end |
556 | 596 |
557 should "test the PNG format" | 597 should "test the PNG format" |
618 @issue = Issue.generate!(:fixed_version => @version, | 658 @issue = Issue.generate!(:fixed_version => @version, |
619 :subject => "gantt#line_for_project", | 659 :subject => "gantt#line_for_project", |
620 :tracker => @tracker, | 660 :tracker => @tracker, |
621 :project => @project, | 661 :project => @project, |
622 :done_ratio => 30, | 662 :done_ratio => 30, |
623 :start_date => Date.yesterday, | 663 :start_date => 1.week.ago.to_date, |
624 :due_date => 1.week.from_now.to_date) | 664 :due_date => 1.week.from_now.to_date) |
625 @project.issues << @issue | 665 @project.issues << @issue |
626 end | 666 end |
627 | 667 |
628 context ":html format" do | 668 context ":html format" do |
629 context "todo line" do | 669 context "todo line" do |
630 should "start from the starting point on the left" do | 670 should "start from the starting point on the left" do |
631 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | 671 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) |
632 assert_select "div.task_todo[style*=left:52px]" | 672 assert_select "div.task_todo[style*=left:28px]", true, @response.body |
633 end | 673 end |
634 | 674 |
635 should "be the total width of the issue" do | 675 should "be the total width of the issue" do |
636 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | 676 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) |
637 assert_select "div.task_todo[style*=width:34px]" | 677 assert_select "div.task_todo[style*=width:58px]", true, @response.body |
638 end | 678 end |
639 | 679 |
640 end | 680 end |
641 | 681 |
642 context "late line" do | 682 context "late line" do |
643 should "start from the starting point on the left" do | 683 should "start from the starting point on the left" do |
644 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | 684 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) |
645 assert_select "div.task_late[style*=left:52px]" | 685 assert_select "div.task_late[style*=left:28px]", true, @response.body |
646 end | 686 end |
647 | 687 |
648 should "be the total delayed width of the issue" do | 688 should "be the total delayed width of the issue" do |
649 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | 689 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) |
650 assert_select "div.task_late[style*=width:6px]" | 690 assert_select "div.task_late[style*=width:30px]", true, @response.body |
651 end | 691 end |
652 end | 692 end |
653 | 693 |
654 context "done line" do | 694 context "done line" do |
655 should "start from the starting point on the left" do | 695 should "start from the starting point on the left" do |
656 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | 696 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) |
657 assert_select "div.task_done[style*=left:52px]" | 697 assert_select "div.task_done[style*=left:28px]", true, @response.body |
658 end | 698 end |
659 | 699 |
660 should "Be the total done width of the issue" do | 700 should "Be the total done width of the issue" do |
661 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | 701 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) |
662 assert_select "div.task_done[style*=left:52px]" | 702 assert_select "div.task_done[style*=width:18px]", true, @response.body |
703 end | |
704 | |
705 should "not be the total done width if the chart starts after issue start date" do | |
706 create_gantt(@project, :date_from => 5.days.ago.to_date) | |
707 | |
708 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
709 assert_select "div.task_done[style*=left:0px]", true, @response.body | |
710 assert_select "div.task_done[style*=width:10px]", true, @response.body | |
663 end | 711 end |
664 end | 712 end |
665 | 713 |
666 context "status content" do | 714 context "status content" do |
667 should "appear at the far left, even if it's far in the past" do | 715 should "appear at the far left, even if it's far in the past" do |
668 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) | 716 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
669 | 717 |
670 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | 718 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) |
671 assert_select "div.issue-name" | 719 assert_select "div.task.label", true, @response.body |
672 end | 720 end |
673 | 721 |
674 should "show the issue status" do | 722 should "show the issue status" do |
675 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | 723 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) |
676 assert_select "div.issue-name", /#{@issue.status.name}/ | 724 assert_select "div.task.label", /#{@issue.status.name}/ |
677 end | 725 end |
678 | 726 |
679 should "show the percent complete" do | 727 should "show the percent complete" do |
680 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | 728 @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) |
681 assert_select "div.issue-name", /30%/ | 729 assert_select "div.task.label", /30%/ |
682 end | 730 end |
683 end | 731 end |
684 end | 732 end |
685 | 733 |
686 should "have an issue tooltip" do | 734 should "have an issue tooltip" do |