annotate .svn/pristine/d8/d87bb15034cb1df578fd9d349f69712ac9695482.svn-base @ 1327:287f201c2802 redmine-2.2-integration

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