Revision 441:cbce1fd3b1b7 test/unit/lib/redmine/helpers/.svn/text-base
| test/unit/lib/redmine/helpers/.svn/text-base/gantt_test.rb.svn-base | ||
|---|---|---|
| 1 |
# redMine - project management software
|
|
| 2 |
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
|
| 1 |
# Redmine - project management software
|
|
| 2 |
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
|
| 3 | 3 |
# |
| 4 | 4 |
# This program is free software; you can redistribute it and/or |
| 5 | 5 |
# modify it under the terms of the GNU General Public License |
| ... | ... | |
| 95 | 95 |
setup do |
| 96 | 96 |
create_gantt |
| 97 | 97 |
end |
| 98 |
|
|
| 99 |
should "clear the @query.project so cross-project issues and versions can be counted" do |
|
| 100 |
assert @gantt.query.project |
|
| 101 |
@gantt.number_of_rows_on_project(@project) |
|
| 102 |
assert_nil @gantt.query.project |
|
| 103 |
end |
|
| 104 | 98 |
|
| 105 |
should "count 1 for the project itself" do
|
|
| 106 |
assert_equal 1, @gantt.number_of_rows_on_project(@project)
|
|
| 99 |
should "count 0 for an empty the project" do
|
|
| 100 |
assert_equal 0, @gantt.number_of_rows_on_project(@project)
|
|
| 107 | 101 |
end |
| 108 | 102 |
|
| 109 | 103 |
should "count the number of issues without a version" do |
| ... | ... | |
| 111 | 105 |
assert_equal 2, @gantt.number_of_rows_on_project(@project) |
| 112 | 106 |
end |
| 113 | 107 |
|
| 114 |
should "count the number of versions" do |
|
| 115 |
@project.versions << Version.generate! |
|
| 116 |
@project.versions << Version.generate! |
|
| 117 |
assert_equal 3, @gantt.number_of_rows_on_project(@project) |
|
| 118 |
end |
|
| 119 |
|
|
| 120 | 108 |
should "count the number of issues on versions, including cross-project" do |
| 121 | 109 |
version = Version.generate! |
| 122 | 110 |
@project.versions << version |
| ... | ... | |
| 124 | 112 |
|
| 125 | 113 |
assert_equal 3, @gantt.number_of_rows_on_project(@project) |
| 126 | 114 |
end |
| 127 |
|
|
| 128 |
should "recursive and count the number of rows on each subproject" do |
|
| 129 |
@project.versions << Version.generate! # +1 |
|
| 130 |
|
|
| 131 |
@subproject = Project.generate!(:enabled_module_names => ['issue_tracking']) # +1 |
|
| 132 |
@subproject.set_parent!(@project) |
|
| 133 |
@subproject.issues << Issue.generate_for_project!(@subproject) # +1 |
|
| 134 |
@subproject.issues << Issue.generate_for_project!(@subproject) # +1 |
|
| 135 |
|
|
| 136 |
@subsubproject = Project.generate!(:enabled_module_names => ['issue_tracking']) # +1 |
|
| 137 |
@subsubproject.set_parent!(@subproject) |
|
| 138 |
@subsubproject.issues << Issue.generate_for_project!(@subsubproject) # +1 |
|
| 139 |
|
|
| 140 |
assert_equal 7, @gantt.number_of_rows_on_project(@project) # +1 for self |
|
| 141 |
end |
|
| 142 | 115 |
end |
| 143 | 116 |
|
| 144 | 117 |
# TODO: more of an integration test |
| ... | ... | |
| 183 | 156 |
@response.body = @gantt.subjects |
| 184 | 157 |
assert_select "div.version-name[style*=left:24px]" |
| 185 | 158 |
end |
| 159 |
|
|
| 160 |
context "without assigned issues" do |
|
| 161 |
setup do |
|
| 162 |
@version = Version.generate!(:effective_date => 2.week.from_now.to_date, :sharing => 'none', :name => 'empty_version') |
|
| 163 |
@project.versions << @version |
|
| 164 |
end |
|
| 165 |
|
|
| 166 |
should "not be rendered" do |
|
| 167 |
@response.body = @gantt.subjects |
|
| 168 |
assert_select "div.version-name a", :text => /#{@version.name}/, :count => 0
|
|
| 169 |
end |
|
| 170 |
end |
|
| 186 | 171 |
end |
| 187 | 172 |
|
| 188 | 173 |
context "issue" do |
| ... | ... | |
| 196 | 181 |
assert_select "div.issue-subject[style*=left:44px]" |
| 197 | 182 |
end |
| 198 | 183 |
|
| 184 |
context "assigned to a shared version of another project" do |
|
| 185 |
setup do |
|
| 186 |
p = Project.generate! |
|
| 187 |
p.trackers << @tracker |
|
| 188 |
p.enabled_module_names = [:issue_tracking] |
|
| 189 |
@shared_version = Version.generate!(:sharing => 'system') |
|
| 190 |
p.versions << @shared_version |
|
| 191 |
# Reassign the issue to a shared version of another project |
|
| 192 |
|
|
| 193 |
@issue = Issue.generate!(:fixed_version => @shared_version, |
|
| 194 |
:subject => "gantt#assigned_to_shared_version", |
|
| 195 |
:tracker => @tracker, |
|
| 196 |
:project => @project, |
|
| 197 |
:done_ratio => 30, |
|
| 198 |
:start_date => Date.yesterday, |
|
| 199 |
:due_date => 1.week.from_now.to_date) |
|
| 200 |
@project.issues << @issue |
|
| 201 |
end |
|
| 202 |
|
|
| 203 |
should "be rendered" do |
|
| 204 |
@response.body = @gantt.subjects |
|
| 205 |
assert_select "div.issue-subject", /#{@issue.subject}/
|
|
| 206 |
end |
|
| 207 |
end |
|
| 208 |
|
|
| 199 | 209 |
context "with subtasks" do |
| 200 | 210 |
setup do |
| 201 | 211 |
attrs = {:project => @project, :tracker => @tracker, :fixed_version => @version}
|
| ... | ... | |
| 537 | 547 |
assert_select "div.version.task_done[style*=left:28px]", true, @response.body |
| 538 | 548 |
end |
| 539 | 549 |
|
| 540 |
should "Be the total done width of the version" do
|
|
| 550 |
should "be the total done width of the version" do
|
|
| 541 | 551 |
@response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
|
| 542 |
assert_select "div.version.task_done[style*=width:18px]", true, @response.body
|
|
| 552 |
assert_select "div.version.task_done[style*=width:16px]", true, @response.body
|
|
| 543 | 553 |
end |
| 544 | 554 |
end |
| 545 | 555 |
|
| ... | ... | |
| 697 | 707 |
assert_select "div.task_done[style*=left:28px]", true, @response.body |
| 698 | 708 |
end |
| 699 | 709 |
|
| 700 |
should "Be the total done width of the issue" do
|
|
| 710 |
should "be the total done width of the issue" do
|
|
| 701 | 711 |
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
|
| 702 |
assert_select "div.task_done[style*=width:18px]", true, @response.body |
|
| 712 |
# 15 days * 4 px * 30% - 2 px for borders = 16 px |
|
| 713 |
assert_select "div.task_done[style*=width:16px]", true, @response.body |
|
| 703 | 714 |
end |
| 704 | 715 |
|
| 705 | 716 |
should "not be the total done width if the chart starts after issue start date" do |
| ... | ... | |
| 707 | 718 |
|
| 708 | 719 |
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
|
| 709 | 720 |
assert_select "div.task_done[style*=left:0px]", true, @response.body |
| 710 |
assert_select "div.task_done[style*=width:10px]", true, @response.body |
|
| 721 |
assert_select "div.task_done[style*=width:8px]", true, @response.body |
|
| 722 |
end |
|
| 723 |
|
|
| 724 |
context "for completed issue" do |
|
| 725 |
setup do |
|
| 726 |
@issue.done_ratio = 100 |
|
| 727 |
end |
|
| 728 |
|
|
| 729 |
should "be the total width of the issue" do |
|
| 730 |
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
|
|
| 731 |
assert_select "div.task_done[style*=width:58px]", true, @response.body |
|
| 732 |
end |
|
| 733 |
|
|
| 734 |
should "be the total width of the issue with due_date=start_date" do |
|
| 735 |
@issue.due_date = @issue.start_date |
|
| 736 |
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
|
|
| 737 |
assert_select "div.task_done[style*=width:2px]", true, @response.body |
|
| 738 |
end |
|
| 711 | 739 |
end |
| 712 | 740 |
end |
| 713 | 741 |
|
Also available in: Unified diff