annotate .svn/pristine/d8/d87bb15034cb1df578fd9d349f69712ac9695482.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

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