1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-20 15:31:12 +00:00

Gantt unit tests cleanup.

git-svn-id: http://svn.redmine.org/redmine/trunk@13673 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-11-30 13:28:53 +00:00
parent 47e9796473
commit dacae57a38

View File

@ -18,16 +18,8 @@
require File.expand_path('../../../../../test_helper', __FILE__) require File.expand_path('../../../../../test_helper', __FILE__)
class Redmine::Helpers::GanttHelperTest < ActionView::TestCase class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
fixtures :projects, :trackers, :issue_statuses, :issues, fixtures :trackers, :issue_statuses,
:journals, :journal_details, :enumerations, :users, :issue_categories
:enumerations, :users, :issue_categories,
:projects_trackers,
:roles,
:member_roles,
:members,
:enabled_modules,
:versions,
:groups_users
include ProjectsHelper include ProjectsHelper
include IssuesHelper include IssuesHelper
@ -44,12 +36,16 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
end end
private :today private :today
def gantt_start
@gantt.date_from
end
# Creates a Gantt chart for a 4 week span # Creates a Gantt chart for a 4 week span
def create_gantt(project=Project.generate!, options={}) def create_gantt(project=Project.generate!, options={})
@project = project @project = project
@gantt = Redmine::Helpers::Gantt.new(options) @gantt = Redmine::Helpers::Gantt.new(options)
@gantt.project = @project @gantt.project = @project
@gantt.query = IssueQuery.create!(:project => @project, :name => 'Gantt') @gantt.query = IssueQuery.new(:project => @project, :name => 'Gantt')
@gantt.view = self @gantt.view = self
@gantt.instance_variable_set('@date_from', options[:date_from] || (today - 14)) @gantt.instance_variable_set('@date_from', options[:date_from] || (today - 14))
@gantt.instance_variable_set('@date_to', options[:date_to] || (today + 14)) @gantt.instance_variable_set('@date_to', options[:date_to] || (today + 14))
@ -132,11 +128,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
setup_subjects setup_subjects
@output_buffer = @gantt.subjects @output_buffer = @gantt.subjects
assert_select "div.project-name a", /#{@project.name}/ assert_select "div.project-name a", /#{@project.name}/
end
test "#subjects project should have an indent of 4" do
setup_subjects
@output_buffer = @gantt.subjects
assert_select "div.project-name[style*=left:4px]" assert_select "div.project-name[style*=left:4px]"
end end
@ -144,11 +135,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
setup_subjects setup_subjects
@output_buffer = @gantt.subjects @output_buffer = @gantt.subjects
assert_select "div.version-name a", /#{@version.name}/ assert_select "div.version-name a", /#{@version.name}/
end
test "#subjects version should be indented 24 (one level)" do
setup_subjects
@output_buffer = @gantt.subjects
assert_select "div.version-name[style*=left:24px]" assert_select "div.version-name[style*=left:24px]"
end end
@ -166,11 +152,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
setup_subjects setup_subjects
@output_buffer = @gantt.subjects @output_buffer = @gantt.subjects
assert_select "div.issue-subject", /#{@issue.subject}/ assert_select "div.issue-subject", /#{@issue.subject}/
end
test "#subjects issue should be indented 44 (two levels)" do
setup_subjects
@output_buffer = @gantt.subjects
assert_select "div.issue-subject[style*=left:44px]" assert_select "div.issue-subject[style*=left:44px]"
end end
@ -224,460 +205,217 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @output_buffer assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @output_buffer
end end
context "#lines" do test "#lines" do
setup do create_gantt
create_gantt @project.enabled_module_names = [:issue_tracking]
@project.enabled_module_names = [:issue_tracking] @tracker = Tracker.generate!
@tracker = Tracker.generate! @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 @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, :project => @project,
:project => @project, :done_ratio => 30,
:done_ratio => 30, :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
context "project" do assert_select "div.project.task_todo"
should "be rendered" do assert_select "div.project.starting"
assert_select "div.project.task_todo" assert_select "div.project.ending"
assert_select "div.project.starting" assert_select "div.label.project", /#{@project.name}/
assert_select "div.project.ending"
assert_select "div.label.project", /#{@project.name}/
end
end
context "version" do assert_select "div.version.task_todo"
should "be rendered" do assert_select "div.version.starting"
assert_select "div.version.task_todo" assert_select "div.version.ending"
assert_select "div.version.starting" assert_select "div.label.version", /#{@version.name}/
assert_select "div.version.ending"
assert_select "div.label.version", /#{@version.name}/
end
end
context "issue" do assert_select "div.task_todo"
should "be rendered" do assert_select "div.task.label", /#{@issue.done_ratio}/
assert_select "div.task_todo" assert_select "div.tooltip", /#{@issue.subject}/
assert_select "div.task.label", /#{@issue.done_ratio}/
assert_select "div.tooltip", /#{@issue.subject}/
end
end
end end
context "#subject_for_project" do test "#subject_for_project" do
setup do create_gantt
create_gantt @output_buffer = @gantt.subject_for_project(@project, :format => :html)
end assert_select 'a[href=?]', "/projects/#{@project.identifier}", :text => /#{@project.name}/
context ":html format" do
should "add an absolute positioned div" do
@output_buffer = @gantt.subject_for_project(@project, {:format => :html})
assert_select "div[style*=absolute]"
end
should "use the indent option to move the div to the right" do
@output_buffer = @gantt.subject_for_project(@project, {:format => :html, :indent => 40})
assert_select "div[style*=left:40]"
end
should "include the project name" do
@output_buffer = @gantt.subject_for_project(@project, {:format => :html})
assert_select 'div', :text => /#{@project.name}/
end
should "include a link to the project" do
@output_buffer = @gantt.subject_for_project(@project, {:format => :html})
assert_select 'a[href=?]', "/projects/#{@project.identifier}", :text => /#{@project.name}/
end
should "style overdue projects" do
@project.enabled_module_names = [:issue_tracking]
@project.versions << Version.generate!(:effective_date => (today - 1))
assert @project.reload.overdue?, "Need an overdue project for this test"
@output_buffer = @gantt.subject_for_project(@project, {:format => :html})
assert_select 'div span.project-overdue'
end
end
end end
context "#line_for_project" do test "#subject_for_project should style overdue projects" do
setup do create_gantt
create_gantt @project.stubs(:overdue?).returns(true)
@project.enabled_module_names = [:issue_tracking] @output_buffer = @gantt.subject_for_project(@project, :format => :html)
@tracker = Tracker.generate! assert_select 'div span.project-overdue'
@project.trackers << @tracker
@version = Version.generate!(:effective_date => (today - 1))
@project.versions << @version
@project.issues << Issue.generate!(:fixed_version => @version,
:subject => "gantt#line_for_project",
:tracker => @tracker,
:project => @project,
:done_ratio => 30,
:start_date => (today - 7),
:due_date => (today + 7))
end
context ":html format" do
context "todo line" do
should "start from the starting point on the left" do
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.task_todo[style*=left:28px]", true, @output_buffer
end
should "be the total width of the project" do
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.task_todo[style*=width:58px]", true, @output_buffer
end
end
context "starting marker" do
should "not appear if the starting point is off the gantt chart" do
# Shift the date range of the chart
@gantt.instance_variable_set('@date_from', today)
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.starting", false, @output_buffer
end
should "appear at the starting point" do
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.starting[style*=left:28px]", true, @output_buffer
end
end
context "ending marker" do
should "not appear if the starting point is off the gantt chart" do
# Shift the date range of the chart
@gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.ending", false, @output_buffer
end
should "appear at the end of the date range" do
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.ending[style*=left:88px]", true, @output_buffer
end
end
context "status content" do
should "appear at the far left, even if it's far in the past" do
@gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.label", /#{@project.name}/
end
should "show the project name" do
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.label", /#{@project.name}/
end
end
end
end end
context "#subject_for_version" do test "#subject_for_version" do
setup do create_gantt
create_gantt version = Version.generate!(:name => 'Foo', :effective_date => today, :project => @project)
@project.enabled_module_names = [:issue_tracking] @output_buffer = @gantt.subject_for_version(version, :format => :html)
@tracker = Tracker.generate! assert_select 'a[href=?]', "/versions/#{version.to_param}", :text => /Foo/
@project.trackers << @tracker
@version = Version.generate!(:effective_date => (today - 1))
@project.versions << @version
@project.issues << Issue.generate!(:fixed_version => @version,
:subject => "gantt#subject_for_version",
:tracker => @tracker,
:project => @project,
:start_date => today)
end
context ":html format" do
should "add an absolute positioned div" do
@output_buffer = @gantt.subject_for_version(@version, {:format => :html})
assert_select "div[style*=absolute]"
end
should "use the indent option to move the div to the right" do
@output_buffer = @gantt.subject_for_version(@version, {:format => :html, :indent => 40})
assert_select "div[style*=left:40]"
end
should "include the version name" do
@output_buffer = @gantt.subject_for_version(@version, {:format => :html})
assert_select 'div', :text => /#{@version.name}/
end
should "include a link to the version" do
@output_buffer = @gantt.subject_for_version(@version, {:format => :html})
assert_select 'a[href=?]', Regexp.escape("/versions/#{@version.to_param}"), :text => /#{@version.name}/
end
should "style late versions" do
assert @version.overdue?, "Need an overdue version for this test"
@output_buffer = @gantt.subject_for_version(@version, {:format => :html})
assert_select 'div span.version-behind-schedule'
end
should "style behind schedule versions" do
assert @version.behind_schedule?, "Need a behind schedule version for this test"
@output_buffer = @gantt.subject_for_version(@version, {:format => :html})
assert_select 'div span.version-behind-schedule'
end
end
end end
context "#line_for_version" do test "#subject_for_version should style overdue versions" do
setup do create_gantt
create_gantt version = Version.generate!(:name => 'Foo', :effective_date => today, :project => @project)
@project.enabled_module_names = [:issue_tracking] version.stubs(:overdue?).returns(true)
@tracker = Tracker.generate! @output_buffer = @gantt.subject_for_version(version, :format => :html)
@project.trackers << @tracker assert_select 'div span.version-overdue'
@version = Version.generate!(:effective_date => (today + 7))
@project.versions << @version
@project.issues << Issue.generate!(:fixed_version => @version,
:subject => "gantt#line_for_project",
:tracker => @tracker,
:project => @project,
:done_ratio => 30,
:start_date => (today - 7),
:due_date => (today + 7))
end
context ":html format" do
context "todo line" do
should "start from the starting point on the left" do
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_todo[style*=left:28px]", true, @output_buffer
end
should "be the total width of the version" do
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_todo[style*=width:58px]", true, @output_buffer
end
end
context "late line" do
should "start from the starting point on the left" do
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_late[style*=left:28px]", true, @output_buffer
end
should "be the total delayed width of the version" do
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_late[style*=width:30px]", true, @output_buffer
end
end
context "done line" do
should "start from the starting point on the left" do
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_done[style*=left:28px]", true, @output_buffer
end
should "be the total done width of the version" do
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_done[style*=width:16px]", true, @output_buffer
end
end
context "starting marker" do
should "not appear if the starting point is off the gantt chart" do
# Shift the date range of the chart
@gantt.instance_variable_set('@date_from', today)
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.starting", false
end
should "appear at the starting point" do
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.starting[style*=left:28px]", true, @output_buffer
end
end
context "ending marker" do
should "not appear if the starting point is off the gantt chart" do
# Shift the date range of the chart
@gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.ending", false
end
should "appear at the end of the date range" do
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.ending[style*=left:88px]", true, @output_buffer
end
end
context "status content" do
should "appear at the far left, even if it's far in the past" do
@gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.label", /#{@version.name}/
end
should "show the version name" do
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.label", /#{@version.name}/
end
should "show the percent complete" do
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.label", /30%/
end
end
end
end end
context "#subject_for_issue" do test "#subject_for_version should style behind schedule versions" do
setup do create_gantt
create_gantt version = Version.generate!(:name => 'Foo', :effective_date => today, :project => @project)
@project.enabled_module_names = [:issue_tracking] version.stubs(:behind_schedule?).returns(true)
@tracker = Tracker.generate! @output_buffer = @gantt.subject_for_version(version, :format => :html)
@project.trackers << @tracker assert_select 'div span.version-behind-schedule'
@issue = Issue.generate!(:subject => "gantt#subject_for_issue",
:tracker => @tracker,
:project => @project,
:start_date => (today - 3),
:due_date => (today - 1))
@project.issues << @issue
end
context ":html format" do
should "add an absolute positioned div" do
@output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
assert_select "div[style*=absolute]"
end
should "use the indent option to move the div to the right" do
@output_buffer = @gantt.subject_for_issue(@issue, {:format => :html, :indent => 40})
assert_select "div[style*=left:40]"
end
should "include the issue subject" do
@output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
assert_select 'div', :text => /#{@issue.subject}/
end
should "include a link to the issue" do
@output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
assert_select 'a[href=?]', Regexp.escape("/issues/#{@issue.to_param}"), :text => /#{@tracker.name} ##{@issue.id}/
end
should "style overdue issues" do
assert @issue.overdue?, "Need an overdue issue for this test"
@output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
assert_select 'div span.issue-overdue'
end
end
end end
context "#line_for_issue" do test "#subject_for_issue" do
setup do create_gantt
create_gantt issue = Issue.generate!(:project => @project)
@project.enabled_module_names = [:issue_tracking] @output_buffer = @gantt.subject_for_issue(issue, :format => :html)
@tracker = Tracker.generate! assert_select 'div', :text => /#{issue.subject}/
@project.trackers << @tracker assert_select 'a[href=?]', "/issues/#{issue.to_param}", :text => /#{issue.tracker.name} ##{issue.id}/
@version = Version.generate!(:effective_date => (today + 7)) end
@project.versions << @version
@issue = Issue.generate!(:fixed_version => @version,
:subject => "gantt#line_for_project",
:tracker => @tracker,
:project => @project,
:done_ratio => 30,
:start_date => (today - 7),
:due_date => (today + 7))
@project.issues << @issue
end
context ":html format" do test "#subject_for_issue should style overdue issues" do
context "todo line" do create_gantt
should "start from the starting point on the left" do issue = Issue.generate!(:project => @project)
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) issue.stubs(:overdue?).returns(true)
assert_select "div.task_todo[style*=left:28px]", true, @output_buffer @output_buffer = @gantt.subject_for_issue(issue, :format => :html)
end assert_select 'div span.issue-overdue'
end
should "be the total width of the issue" do test "#subject should add an absolute positioned div" do
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) create_gantt
assert_select "div.task_todo[style*=width:58px]", true, @output_buffer @output_buffer = @gantt.subject('subject', :format => :html)
end assert_select "div[style*=absolute]", :text => 'subject'
end end
context "late line" do test "#subject should use the indent option to move the div to the right" do
should "start from the starting point on the left" do create_gantt
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.subject('subject', :format => :html, :indent => 40)
assert_select "div.task_late[style*=left:28px]", true, @output_buffer assert_select "div[style*=left:40]"
end end
should "be the total delayed width of the issue" do test "#line_for_project" do
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) create_gantt
assert_select "div.task_late[style*=width:30px]", true, @output_buffer @project.stubs(:start_date).returns(today - 7)
end @project.stubs(:due_date).returns(today + 7)
end @output_buffer = @gantt.line_for_project(@project, :format => :html)
assert_select "div.project.label", :text => @project.name
end
context "done line" do test "#line_for_version" do
should "start from the starting point on the left" do create_gantt
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) version = Version.generate!(:name => 'Foo', :project => @project)
assert_select "div.task_done[style*=left:28px]", true, @output_buffer version.stubs(:start_date).returns(today - 7)
end version.stubs(:due_date).returns(today + 7)
version.stubs(:completed_percent).returns(30)
@output_buffer = @gantt.line_for_version(version, :format => :html)
assert_select "div.version.label", :text => /Foo/
assert_select "div.version.label", :text => /30%/
end
should "be the total done width of the issue" do test "#line_for_issue" do
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) create_gantt
# 15 days * 4 px * 30% - 2 px for borders = 16 px issue = Issue.generate!(:project => @project, :start_date => today - 7, :due_date => today + 7, :done_ratio => 30)
assert_select "div.task_done[style*=width:16px]", true, @output_buffer @output_buffer = @gantt.line_for_issue(issue, :format => :html)
end assert_select "div.task.label", :text => /#{issue.status.name}/
assert_select "div.task.label", :text => /30%/
assert_select "div.tooltip", /#{issue.subject}/
end
should "not be the total done width if the chart starts after issue start date" do test "#line todo line should start from the starting point on the left" do
create_gantt(@project, :date_from => (today - 5)) create_gantt
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
assert_select "div.task_done[style*=left:0px]", true, @output_buffer assert_select "div.task_todo[style*=left:28px]", 1
assert_select "div.task_done[style*=width:8px]", true, @output_buffer end
end
context "for completed issue" do test "#line todo line should be the total width" do
setup do create_gantt
@issue.done_ratio = 100 @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
end assert_select "div.task_todo[style*=width:58px]", 1
end
should "be the total width of the issue" do test "#line late line should start from the starting point on the left" do
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) create_gantt
assert_select "div.task_done[style*=width:58px]", true, @output_buffer @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
end assert_select "div.task_late[style*=left:28px]", 1
end
should "be the total width of the issue with due_date=start_date" do test "#line late line should be the total delayed width" do
@issue.due_date = @issue.start_date create_gantt
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
assert_select "div.task_done[style*=width:2px]", true, @output_buffer assert_select "div.task_late[style*=width:30px]", 1
end end
end
end
context "status content" do test "#line done line should start from the starting point on the left" do
should "appear at the far left, even if it's far in the past" do create_gantt
@gantt.instance_variable_set('@date_to', (today - 14)) @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) assert_select "div.task_done[style*=left:28px]", 1
assert_select "div.task.label", true, @output_buffer end
end
should "show the issue status" do test "#line done line should be the width for the done ratio" do
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) create_gantt
assert_select "div.task.label", /#{@issue.status.name}/ @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
end # 15 days * 4 px * 30% - 2 px for borders = 16 px
assert_select "div.task_done[style*=width:16px]", 1
end
should "show the percent complete" do test "#line done line should be the total width for 100% done ratio" do
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) create_gantt
assert_select "div.task.label", /30%/ @output_buffer = @gantt.line(today - 7, today + 7, 100, false, 'line', :format => :html, :zoom => 4)
end # 15 days * 4 px - 2 px for borders = 58 px
end assert_select "div.task_done[style*=width:58px]", 1
end end
should "have an issue tooltip" do test "#line done line should be the total width for 100% done ratio with same start and end dates" do
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) create_gantt
assert_select "div.tooltip", /#{@issue.subject}/ @output_buffer = @gantt.line(today + 7, today + 7, 100, false, 'line', :format => :html, :zoom => 4)
end assert_select "div.task_done[style*=width:2px]", 1
end
test "#line done line should not be the total done width if the gantt starts after start date" do
create_gantt
@output_buffer = @gantt.line(today - 16, today - 2, 30, false, 'line', :format => :html, :zoom => 4)
assert_select "div.task_done[style*=left:0px]", 1
assert_select "div.task_done[style*=width:8px]", 1
end
test "#line starting marker should appear at the start date" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 30, true, 'line', :format => :html, :zoom => 4)
assert_select "div.starting", 1
assert_select "div.starting[style*=left:28px]", 1
end
test "#line starting marker should not appear if the start date is before gantt start date" do
create_gantt
@output_buffer = @gantt.line(gantt_start - 2, today + 7, 30, true, 'line', :format => :html, :zoom => 4)
assert_select "div.starting", 0
end
test "#line ending marker should appear at the end date" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 30, true, 'line', :format => :html, :zoom => 4)
assert_select "div.ending", 1
assert_select "div.ending[style*=left:88px]", 1
end
test "#line ending marker should not appear if the end date is before gantt start date" do
create_gantt
@output_buffer = @gantt.line(gantt_start - 30, gantt_start - 21, 30, true, 'line', :format => :html)
assert_select "div.ending", 0
end
test "#line label should appear at the far left, even if it's before gantt start date" do
create_gantt
@output_buffer = @gantt.line(gantt_start - 30, gantt_start - 21, 30, true, 'line', :format => :html)
assert_select "div.label", :text => 'line'
end end
def test_sort_issues_no_date def test_sort_issues_no_date
@ -749,11 +487,12 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
def test_sort_versions def test_sort_versions
project = Project.generate! project = Project.generate!
version1 = Version.create!(:project => project, :name => 'test1') versions = []
version2 = Version.create!(:project => project, :name => 'test2', :effective_date => '2013-10-25') versions << Version.create!(:project => project, :name => 'test1')
version3 = Version.create!(:project => project, :name => 'test3') versions << Version.create!(:project => project, :name => 'test2', :effective_date => '2013-10-25')
version4 = Version.create!(:project => project, :name => 'test4', :effective_date => '2013-10-02') versions << Version.create!(:project => project, :name => 'test3')
versions << Version.create!(:project => project, :name => 'test4', :effective_date => '2013-10-02')
assert_equal versions.sort, Redmine::Helpers::Gantt.sort_versions!(versions) assert_equal versions.sort, Redmine::Helpers::Gantt.sort_versions!(versions.dup)
end end
end end