code layout cleanup test/unit/lib/redmine/helpers/gantt_test.rb

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10063 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2012-07-21 08:08:06 +00:00
parent bd85428b01
commit dadd294a25
1 changed files with 21 additions and 38 deletions

View File

@ -56,7 +56,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
end end
context "#number_of_rows" do context "#number_of_rows" do
context "with one project" do context "with one project" do
should "return the number of rows just for that project" should "return the number of rows just for that project"
end end
@ -70,12 +69,10 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
5.times do 5.times do
Issue.generate_for_project!(p) Issue.generate_for_project!(p)
end end
create_gantt(p) create_gantt(p)
@gantt.render @gantt.render
assert_equal 6, @gantt.number_of_rows assert_equal 6, @gantt.number_of_rows
assert !@gantt.truncated assert !@gantt.truncated
create_gantt(p, :max_rows => 3) create_gantt(p, :max_rows => 3)
@gantt.render @gantt.render
assert_equal 3, @gantt.number_of_rows assert_equal 3, @gantt.number_of_rows
@ -101,7 +98,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
version = Version.generate! version = Version.generate!
@project.versions << version @project.versions << version
@project.issues << Issue.generate_for_project!(@project, :fixed_version => version) @project.issues << Issue.generate_for_project!(@project, :fixed_version => version)
assert_equal 3, @gantt.number_of_rows_on_project(@project) assert_equal 3, @gantt.number_of_rows_on_project(@project)
end end
end end
@ -115,7 +111,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
@project.trackers << @tracker @project.trackers << @tracker
@version = Version.generate!(:effective_date => (today + 7), :sharing => 'none') @version = Version.generate!(:effective_date => (today + 7), :sharing => 'none')
@project.versions << @version @project.versions << @version
@issue = Issue.generate!(:fixed_version => @version, @issue = Issue.generate!(:fixed_version => @version,
:subject => "gantt#line_for_project", :subject => "gantt#line_for_project",
:tracker => @tracker, :tracker => @tracker,
@ -151,7 +146,9 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
context "without assigned issues" do context "without assigned issues" do
setup do setup do
@version = Version.generate!(:effective_date => (today + 14), :sharing => 'none', :name => 'empty_version') @version = Version.generate!(:effective_date => (today + 14),
:sharing => 'none',
:name => 'empty_version')
@project.versions << @version @project.versions << @version
end end
@ -180,7 +177,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
@shared_version = Version.generate!(:sharing => 'system') @shared_version = Version.generate!(:sharing => 'system')
p.versions << @shared_version p.versions << @shared_version
# Reassign the issue to a shared version of another project # Reassign the issue to a shared version of another project
@issue = Issue.generate!(:fixed_version => @shared_version, @issue = Issue.generate!(:fixed_version => @shared_version,
:subject => "gantt#assigned_to_shared_version", :subject => "gantt#assigned_to_shared_version",
:tracker => @tracker, :tracker => @tracker,
@ -200,9 +196,24 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
context "with subtasks" do context "with subtasks" do
setup do setup do
attrs = {:project => @project, :tracker => @tracker, :fixed_version => @version} attrs = {:project => @project, :tracker => @tracker, :fixed_version => @version}
@child1 = Issue.generate!(attrs.merge(:subject => 'child1', :parent_issue_id => @issue.id, :start_date => (today - 1), :due_date => (today + 2))) @child1 = Issue.generate!(
@child2 = Issue.generate!(attrs.merge(:subject => 'child2', :parent_issue_id => @issue.id, :start_date => today, :due_date => (today + 7))) attrs.merge(:subject => 'child1',
@grandchild = Issue.generate!(attrs.merge(:subject => 'grandchild', :parent_issue_id => @child1.id, :start_date => (today - 1), :due_date => (today + 2))) :parent_issue_id => @issue.id,
:start_date => (today - 1),
:due_date => (today + 2))
)
@child2 = Issue.generate!(
attrs.merge(:subject => 'child2',
:parent_issue_id => @issue.id,
:start_date => today,
:due_date => (today + 7))
)
@grandchild = Issue.generate!(
attrs.merge(:subject => 'grandchild',
:parent_issue_id => @child1.id,
:start_date => (today - 1),
:due_date => (today + 2))
)
end end
should "indent subtasks" do should "indent subtasks" do
@ -235,7 +246,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
:start_date => (today - 1), :start_date => (today - 1),
:due_date => (today + 7)) :due_date => (today + 7))
@project.issues << @issue @project.issues << @issue
@output_buffer = @gantt.lines @output_buffer = @gantt.lines
end end
@ -307,16 +317,11 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
should "style overdue projects" do should "style overdue projects" do
@project.enabled_module_names = [:issue_tracking] @project.enabled_module_names = [:issue_tracking]
@project.versions << Version.generate!(:effective_date => (today - 1)) @project.versions << Version.generate!(:effective_date => (today - 1))
assert @project.reload.overdue?, "Need an overdue project for this test" assert @project.reload.overdue?, "Need an overdue project for this test"
@output_buffer = @gantt.subject_for_project(@project, {:format => :html}) @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
assert_select 'div span.project-overdue' assert_select 'div span.project-overdue'
end end
end end
should "test the PNG format" should "test the PNG format"
should "test the PDF format" should "test the PDF format"
end end
@ -329,7 +334,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
@project.trackers << @tracker @project.trackers << @tracker
@version = Version.generate!(:effective_date => (today - 1)) @version = Version.generate!(:effective_date => (today - 1))
@project.versions << @version @project.versions << @version
@project.issues << Issue.generate!(:fixed_version => @version, @project.issues << Issue.generate!(:fixed_version => @version,
:subject => "gantt#line_for_project", :subject => "gantt#line_for_project",
:tracker => @tracker, :tracker => @tracker,
@ -350,7 +354,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.task_todo[style*=width:58px]", true, @output_buffer assert_select "div.project.task_todo[style*=width:58px]", true, @output_buffer
end end
end end
context "late line" do context "late line" do
@ -381,7 +384,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
should "not appear if the starting point is off the gantt chart" do should "not appear if the starting point is off the gantt chart" do
# Shift the date range of the chart # Shift the date range of the chart
@gantt.instance_variable_set('@date_from', today) @gantt.instance_variable_set('@date_from', today)
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.starting", false, @output_buffer assert_select "div.project.starting", false, @output_buffer
end end
@ -396,10 +398,8 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
should "not appear if the starting point is off the gantt chart" do should "not appear if the starting point is off the gantt chart" do
# Shift the date range of the chart # Shift the date range of the chart
@gantt.instance_variable_set('@date_to', (today - 14)) @gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.ending", false, @output_buffer assert_select "div.project.ending", false, @output_buffer
end end
should "appear at the end of the date range" do should "appear at the end of the date range" do
@ -427,7 +427,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
end end
end end
end end
should "test the PNG format" should "test the PNG format"
should "test the PDF format" should "test the PDF format"
end end
@ -473,14 +472,12 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
should "style late versions" do should "style late versions" do
assert @version.overdue?, "Need an overdue version for this test" assert @version.overdue?, "Need an overdue version for this test"
@output_buffer = @gantt.subject_for_version(@version, {:format => :html}) @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
assert_select 'div span.version-behind-schedule' assert_select 'div span.version-behind-schedule'
end end
should "style behind schedule versions" do should "style behind schedule versions" do
assert @version.behind_schedule?, "Need a behind schedule version for this test" assert @version.behind_schedule?, "Need a behind schedule version for this test"
@output_buffer = @gantt.subject_for_version(@version, {:format => :html}) @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
assert_select 'div span.version-behind-schedule' assert_select 'div span.version-behind-schedule'
end end
end end
@ -496,7 +493,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
@project.trackers << @tracker @project.trackers << @tracker
@version = Version.generate!(:effective_date => (today + 7)) @version = Version.generate!(:effective_date => (today + 7))
@project.versions << @version @project.versions << @version
@project.issues << Issue.generate!(:fixed_version => @version, @project.issues << Issue.generate!(:fixed_version => @version,
:subject => "gantt#line_for_project", :subject => "gantt#line_for_project",
:tracker => @tracker, :tracker => @tracker,
@ -548,7 +544,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
should "not appear if the starting point is off the gantt chart" do should "not appear if the starting point is off the gantt chart" do
# Shift the date range of the chart # Shift the date range of the chart
@gantt.instance_variable_set('@date_from', today) @gantt.instance_variable_set('@date_from', today)
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.starting", false assert_select "div.version.starting", false
end end
@ -563,10 +558,8 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
should "not appear if the starting point is off the gantt chart" do should "not appear if the starting point is off the gantt chart" do
# Shift the date range of the chart # Shift the date range of the chart
@gantt.instance_variable_set('@date_to', (today - 14)) @gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.ending", false assert_select "div.version.ending", false
end end
should "appear at the end of the date range" do should "appear at the end of the date range" do
@ -578,7 +571,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
context "status content" do context "status content" do
should "appear at the far left, even if it's far in the past" do should "appear at the far left, even if it's far in the past" do
@gantt.instance_variable_set('@date_to', (today - 14)) @gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.label", /#{@version.name}/ assert_select "div.version.label", /#{@version.name}/
end end
@ -594,7 +586,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
end end
end end
end end
should "test the PNG format" should "test the PNG format"
should "test the PDF format" should "test the PDF format"
end end
@ -605,14 +596,12 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
@project.enabled_module_names = [:issue_tracking] @project.enabled_module_names = [:issue_tracking]
@tracker = Tracker.generate! @tracker = Tracker.generate!
@project.trackers << @tracker @project.trackers << @tracker
@issue = Issue.generate!(:subject => "gantt#subject_for_issue", @issue = Issue.generate!(:subject => "gantt#subject_for_issue",
:tracker => @tracker, :tracker => @tracker,
:project => @project, :project => @project,
:start_date => (today - 3), :start_date => (today - 3),
:due_date => (today - 1)) :due_date => (today - 1))
@project.issues << @issue @project.issues << @issue
end end
context ":html format" do context ":html format" do
@ -639,10 +628,8 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
should "style overdue issues" do should "style overdue issues" do
assert @issue.overdue?, "Need an overdue issue for this test" assert @issue.overdue?, "Need an overdue issue for this test"
@output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
assert_select 'div span.issue-overdue' assert_select 'div span.issue-overdue'
end end
end end
should "test the PNG format" should "test the PNG format"
should "test the PDF format" should "test the PDF format"
@ -677,7 +664,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.task_todo[style*=width:58px]", true, @output_buffer assert_select "div.task_todo[style*=width:58px]", true, @output_buffer
end end
end end
context "late line" do context "late line" do
@ -733,7 +719,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
context "status content" do context "status content" do
should "appear at the far left, even if it's far in the past" do should "appear at the far left, even if it's far in the past" do
@gantt.instance_variable_set('@date_to', (today - 14)) @gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.task.label", true, @output_buffer assert_select "div.task.label", true, @output_buffer
end end
@ -754,7 +739,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.tooltip", /#{@issue.subject}/ assert_select "div.tooltip", /#{@issue.subject}/
end end
should "test the PNG format" should "test the PNG format"
should "test the PDF format" should "test the PDF format"
end end
@ -766,5 +750,4 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
context "#to_pdf" do context "#to_pdf" do
should "be tested" should "be tested"
end end
end end