annotate .svn/pristine/08/08671dfda70fdd4f87dd0171bec11e1d6e0c22e1.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

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