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