Test cleanup.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8280 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-12-18 10:14:14 +00:00
parent 914f9b603e
commit b549523e4b
1 changed files with 101 additions and 122 deletions

View File

@ -17,26 +17,13 @@
require File.expand_path('../../../../../test_helper', __FILE__) require File.expand_path('../../../../../test_helper', __FILE__)
class Redmine::Helpers::GanttTest < ActiveSupport::TestCase class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
# Utility methods and classes so assert_select can be used. include ApplicationHelper
class GanttViewTest < ActionView::Base include ProjectsHelper
include ActionView::Helpers::UrlHelper include IssuesHelper
include ActionView::Helpers::TextHelper
include ActionController::UrlWriter
include ApplicationHelper
include ProjectsHelper
include IssuesHelper
def self.default_url_options
{:only_path => true }
end
end
include ActionController::Assertions::SelectorAssertions
def setup def setup
@response = ActionController::TestResponse.new setup_with_controller
# Fixtures # Fixtures
ProjectCustomField.delete_all ProjectCustomField.delete_all
Project.destroy_all Project.destroy_all
@ -44,21 +31,13 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
User.current = User.find(1) User.current = User.find(1)
end end
def build_view
@view = GanttViewTest.new
end
def html_document
HTML::Document.new(@response.body)
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 = Query.generate_default!(:project => @project) @gantt.query = Query.generate_default!(:project => @project)
@gantt.view = build_view @gantt.view = self
@gantt.instance_variable_set('@date_from', options[:date_from] || 2.weeks.ago.to_date) @gantt.instance_variable_set('@date_from', options[:date_from] || 2.weeks.ago.to_date)
@gantt.instance_variable_set('@date_to', options[:date_to] || 2.weeks.from_now.to_date) @gantt.instance_variable_set('@date_to', options[:date_to] || 2.weeks.from_now.to_date)
end end
@ -136,24 +115,24 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
context "project" do context "project" do
should "be rendered" do should "be rendered" do
@response.body = @gantt.subjects @output_buffer = @gantt.subjects
assert_select "div.project-name a", /#{@project.name}/ assert_select "div.project-name a", /#{@project.name}/
end end
should "have an indent of 4" do should "have an indent of 4" do
@response.body = @gantt.subjects @output_buffer = @gantt.subjects
assert_select "div.project-name[style*=left:4px]" assert_select "div.project-name[style*=left:4px]"
end end
end end
context "version" do context "version" do
should "be rendered" do should "be rendered" do
@response.body = @gantt.subjects @output_buffer = @gantt.subjects
assert_select "div.version-name a", /#{@version.name}/ assert_select "div.version-name a", /#{@version.name}/
end end
should "be indented 24 (one level)" do should "be indented 24 (one level)" do
@response.body = @gantt.subjects @output_buffer = @gantt.subjects
assert_select "div.version-name[style*=left:24px]" assert_select "div.version-name[style*=left:24px]"
end end
@ -164,7 +143,7 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
end end
should "not be rendered" do should "not be rendered" do
@response.body = @gantt.subjects @output_buffer = @gantt.subjects
assert_select "div.version-name a", :text => /#{@version.name}/, :count => 0 assert_select "div.version-name a", :text => /#{@version.name}/, :count => 0
end end
end end
@ -172,12 +151,12 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
context "issue" do context "issue" do
should "be rendered" do should "be rendered" do
@response.body = @gantt.subjects @output_buffer = @gantt.subjects
assert_select "div.issue-subject", /#{@issue.subject}/ assert_select "div.issue-subject", /#{@issue.subject}/
end end
should "be indented 44 (two levels)" do should "be indented 44 (two levels)" do
@response.body = @gantt.subjects @output_buffer = @gantt.subjects
assert_select "div.issue-subject[style*=left:44px]" assert_select "div.issue-subject[style*=left:44px]"
end end
@ -201,7 +180,7 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
end end
should "be rendered" do should "be rendered" do
@response.body = @gantt.subjects @output_buffer = @gantt.subjects
assert_select "div.issue-subject", /#{@issue.subject}/ assert_select "div.issue-subject", /#{@issue.subject}/
end end
end end
@ -215,14 +194,14 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
end end
should "indent subtasks" do should "indent subtasks" do
@response.body = @gantt.subjects @output_buffer = @gantt.subjects
# parent task 44px # parent task 44px
assert_select "div.issue-subject[style*=left:44px]", /#{@issue.subject}/ assert_select "div.issue-subject[style*=left:44px]", /#{@issue.subject}/
# children 64px # children 64px
assert_select "div.issue-subject[style*=left:64px]", /child1/ assert_select "div.issue-subject[style*=left:64px]", /child1/
assert_select "div.issue-subject[style*=left:64px]", /child2/ assert_select "div.issue-subject[style*=left:64px]", /child2/
# grandchild 84px # grandchild 84px
assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @response.body assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @output_buffer
end end
end end
end end
@ -245,7 +224,7 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
:due_date => 1.week.from_now.to_date) :due_date => 1.week.from_now.to_date)
@project.issues << @issue @project.issues << @issue
@response.body = @gantt.lines @output_buffer = @gantt.lines
end end
context "project" do context "project" do
@ -294,22 +273,22 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
context ":html format" do context ":html format" do
should "add an absolute positioned div" do should "add an absolute positioned div" do
@response.body = @gantt.subject_for_project(@project, {:format => :html}) @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
assert_select "div[style*=absolute]" assert_select "div[style*=absolute]"
end end
should "use the indent option to move the div to the right" do should "use the indent option to move the div to the right" do
@response.body = @gantt.subject_for_project(@project, {:format => :html, :indent => 40}) @output_buffer = @gantt.subject_for_project(@project, {:format => :html, :indent => 40})
assert_select "div[style*=left:40]" assert_select "div[style*=left:40]"
end end
should "include the project name" do should "include the project name" do
@response.body = @gantt.subject_for_project(@project, {:format => :html}) @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
assert_select 'div', :text => /#{@project.name}/ assert_select 'div', :text => /#{@project.name}/
end end
should "include a link to the project" do should "include a link to the project" do
@response.body = @gantt.subject_for_project(@project, {:format => :html}) @output_buffer = @gantt.subject_for_project(@project, {:format => :html})
assert_select 'a[href=?]', "/projects/#{@project.identifier}", :text => /#{@project.name}/ assert_select 'a[href=?]', "/projects/#{@project.identifier}", :text => /#{@project.name}/
end end
@ -318,7 +297,7 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
@project.versions << Version.generate!(:effective_date => Date.yesterday) @project.versions << Version.generate!(:effective_date => Date.yesterday)
assert @project.overdue?, "Need an overdue project for this test" assert @project.overdue?, "Need an overdue project for this test"
@response.body = @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
@ -351,38 +330,38 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
context ":html format" do context ":html format" do
context "todo line" do context "todo line" do
should "start from the starting point on the left" do should "start from the starting point on the left" do
@response.body = @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*=left:28px]", true, @response.body assert_select "div.project.task_todo[style*=left:28px]", true, @output_buffer
end end
should "be the total width of the project" do should "be the total width of the project" do
@response.body = @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, @response.body assert_select "div.project.task_todo[style*=width:58px]", true, @output_buffer
end end
end end
context "late line" do context "late line" do
should_eventually "start from the starting point on the left" do should_eventually "start from the starting point on the left" do
@response.body = @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_late[style*=left:28px]", true, @response.body assert_select "div.project.task_late[style*=left:28px]", true, @output_buffer
end end
should_eventually "be the total delayed width of the project" do should_eventually "be the total delayed width of the project" do
@response.body = @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_late[style*=width:30px]", true, @response.body assert_select "div.project.task_late[style*=width:30px]", true, @output_buffer
end end
end end
context "done line" do context "done line" do
should_eventually "start from the starting point on the left" do should_eventually "start from the starting point on the left" do
@response.body = @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_done[style*=left:28px]", true, @response.body assert_select "div.project.task_done[style*=left:28px]", true, @output_buffer
end end
should_eventually "Be the total done width of the project" do should_eventually "Be the total done width of the project" do
@response.body = @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_done[style*=width:18px]", true, @response.body assert_select "div.project.task_done[style*=width:18px]", true, @output_buffer
end end
end end
@ -391,13 +370,13 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
# Shift the date range of the chart # Shift the date range of the chart
@gantt.instance_variable_set('@date_from', Date.today) @gantt.instance_variable_set('@date_from', Date.today)
@response.body = @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, @response.body assert_select "div.project.starting", false, @output_buffer
end end
should "appear at the starting point" do should "appear at the starting point" do
@response.body = @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[style*=left:28px]", true, @response.body assert_select "div.project.starting[style*=left:28px]", true, @output_buffer
end end
end end
@ -406,14 +385,14 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
# Shift the date range of the chart # Shift the date range of the chart
@gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
@response.body = @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, @response.body 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
@response.body = @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[style*=left:88px]", true, @response.body assert_select "div.project.ending[style*=left:88px]", true, @output_buffer
end end
end end
@ -421,17 +400,17 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
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', 2.weeks.ago.to_date) @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
@response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.label", /#{@project.name}/ assert_select "div.project.label", /#{@project.name}/
end end
should "show the project name" do should "show the project name" do
@response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.label", /#{@project.name}/ assert_select "div.project.label", /#{@project.name}/
end end
should_eventually "show the percent complete" do should_eventually "show the percent complete" do
@response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.label", /0%/ assert_select "div.project.label", /0%/
end end
end end
@ -460,35 +439,35 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
context ":html format" do context ":html format" do
should "add an absolute positioned div" do should "add an absolute positioned div" do
@response.body = @gantt.subject_for_version(@version, {:format => :html}) @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
assert_select "div[style*=absolute]" assert_select "div[style*=absolute]"
end end
should "use the indent option to move the div to the right" do should "use the indent option to move the div to the right" do
@response.body = @gantt.subject_for_version(@version, {:format => :html, :indent => 40}) @output_buffer = @gantt.subject_for_version(@version, {:format => :html, :indent => 40})
assert_select "div[style*=left:40]" assert_select "div[style*=left:40]"
end end
should "include the version name" do should "include the version name" do
@response.body = @gantt.subject_for_version(@version, {:format => :html}) @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
assert_select 'div', :text => /#{@version.name}/ assert_select 'div', :text => /#{@version.name}/
end end
should "include a link to the version" do should "include a link to the version" do
@response.body = @gantt.subject_for_version(@version, {:format => :html}) @output_buffer = @gantt.subject_for_version(@version, {:format => :html})
assert_select 'a[href=?]', Regexp.escape("/versions/#{@version.to_param}"), :text => /#{@version.name}/ assert_select 'a[href=?]', Regexp.escape("/versions/#{@version.to_param}"), :text => /#{@version.name}/
end end
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"
@response.body = @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"
@response.body = @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
@ -518,38 +497,38 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
context ":html format" do context ":html format" do
context "todo line" do context "todo line" do
should "start from the starting point on the left" do should "start from the starting point on the left" do
@response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_todo[style*=left:28px]", true, @response.body assert_select "div.version.task_todo[style*=left:28px]", true, @output_buffer
end end
should "be the total width of the version" do should "be the total width of the version" do
@response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_todo[style*=width:58px]", true, @response.body assert_select "div.version.task_todo[style*=width:58px]", true, @output_buffer
end end
end end
context "late line" do context "late line" do
should "start from the starting point on the left" do should "start from the starting point on the left" do
@response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_late[style*=left:28px]", true, @response.body assert_select "div.version.task_late[style*=left:28px]", true, @output_buffer
end end
should "be the total delayed width of the version" do should "be the total delayed width of the version" do
@response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_late[style*=width:30px]", true, @response.body assert_select "div.version.task_late[style*=width:30px]", true, @output_buffer
end end
end end
context "done line" do context "done line" do
should "start from the starting point on the left" do should "start from the starting point on the left" do
@response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_done[style*=left:28px]", true, @response.body assert_select "div.version.task_done[style*=left:28px]", true, @output_buffer
end end
should "be the total done width of the version" do should "be the total done width of the version" do
@response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.task_done[style*=width:16px]", true, @response.body assert_select "div.version.task_done[style*=width:16px]", true, @output_buffer
end end
end end
@ -558,13 +537,13 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
# Shift the date range of the chart # Shift the date range of the chart
@gantt.instance_variable_set('@date_from', Date.today) @gantt.instance_variable_set('@date_from', Date.today)
@response.body = @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
should "appear at the starting point" do should "appear at the starting point" do
@response.body = @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[style*=left:28px]", true, @response.body assert_select "div.version.starting[style*=left:28px]", true, @output_buffer
end end
end end
@ -573,14 +552,14 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
# Shift the date range of the chart # Shift the date range of the chart
@gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
@response.body = @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
@response.body = @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[style*=left:88px]", true, @response.body assert_select "div.version.ending[style*=left:88px]", true, @output_buffer
end end
end end
@ -588,17 +567,17 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
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', 2.weeks.ago.to_date) @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
@response.body = @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
should "show the version name" do should "show the version name" do
@response.body = @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
should "show the percent complete" do should "show the percent complete" do
@response.body = @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", /30%/ assert_select "div.version.label", /30%/
end end
end end
@ -626,28 +605,28 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
context ":html format" do context ":html format" do
should "add an absolute positioned div" do should "add an absolute positioned div" do
@response.body = @gantt.subject_for_issue(@issue, {:format => :html}) @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
assert_select "div[style*=absolute]" assert_select "div[style*=absolute]"
end end
should "use the indent option to move the div to the right" do should "use the indent option to move the div to the right" do
@response.body = @gantt.subject_for_issue(@issue, {:format => :html, :indent => 40}) @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html, :indent => 40})
assert_select "div[style*=left:40]" assert_select "div[style*=left:40]"
end end
should "include the issue subject" do should "include the issue subject" do
@response.body = @gantt.subject_for_issue(@issue, {:format => :html}) @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
assert_select 'div', :text => /#{@issue.subject}/ assert_select 'div', :text => /#{@issue.subject}/
end end
should "include a link to the issue" do should "include a link to the issue" do
@response.body = @gantt.subject_for_issue(@issue, {:format => :html}) @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html})
assert_select 'a[href=?]', Regexp.escape("/issues/#{@issue.to_param}"), :text => /#{@tracker.name} ##{@issue.id}/ assert_select 'a[href=?]', Regexp.escape("/issues/#{@issue.to_param}"), :text => /#{@tracker.name} ##{@issue.id}/
end end
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"
@response.body = @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
@ -678,47 +657,47 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
context ":html format" do context ":html format" do
context "todo line" do context "todo line" do
should "start from the starting point on the left" do should "start from the starting point on the left" do
@response.body = @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*=left:28px]", true, @response.body assert_select "div.task_todo[style*=left:28px]", true, @output_buffer
end end
should "be the total width of the issue" do should "be the total width of the issue" do
@response.body = @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, @response.body assert_select "div.task_todo[style*=width:58px]", true, @output_buffer
end end
end end
context "late line" do context "late line" do
should "start from the starting point on the left" do should "start from the starting point on the left" do
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.task_late[style*=left:28px]", true, @response.body assert_select "div.task_late[style*=left:28px]", true, @output_buffer
end end
should "be the total delayed width of the issue" do should "be the total delayed width of the issue" do
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.task_late[style*=width:30px]", true, @response.body assert_select "div.task_late[style*=width:30px]", true, @output_buffer
end end
end end
context "done line" do context "done line" do
should "start from the starting point on the left" do should "start from the starting point on the left" do
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.task_done[style*=left:28px]", true, @response.body assert_select "div.task_done[style*=left:28px]", true, @output_buffer
end end
should "be the total done width of the issue" do should "be the total done width of the issue" do
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
# 15 days * 4 px * 30% - 2 px for borders = 16 px # 15 days * 4 px * 30% - 2 px for borders = 16 px
assert_select "div.task_done[style*=width:16px]", true, @response.body assert_select "div.task_done[style*=width:16px]", true, @output_buffer
end end
should "not be the total done width if the chart starts after issue start date" do should "not be the total done width if the chart starts after issue start date" do
create_gantt(@project, :date_from => 5.days.ago.to_date) create_gantt(@project, :date_from => 5.days.ago.to_date)
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.task_done[style*=left:0px]", true, @response.body assert_select "div.task_done[style*=left:0px]", true, @output_buffer
assert_select "div.task_done[style*=width:8px]", true, @response.body assert_select "div.task_done[style*=width:8px]", true, @output_buffer
end end
context "for completed issue" do context "for completed issue" do
@ -727,14 +706,14 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
end end
should "be the total width of the issue" do should "be the total width of the issue" do
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.task_done[style*=width:58px]", true, @response.body assert_select "div.task_done[style*=width:58px]", true, @output_buffer
end end
should "be the total width of the issue with due_date=start_date" do should "be the total width of the issue with due_date=start_date" do
@issue.due_date = @issue.start_date @issue.due_date = @issue.start_date
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.task_done[style*=width:2px]", true, @response.body assert_select "div.task_done[style*=width:2px]", true, @output_buffer
end end
end end
end end
@ -743,24 +722,24 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
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', 2.weeks.ago.to_date) @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
@response.body = @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, @response.body assert_select "div.task.label", true, @output_buffer
end end
should "show the issue status" do should "show the issue status" do
@response.body = @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", /#{@issue.status.name}/ assert_select "div.task.label", /#{@issue.status.name}/
end end
should "show the percent complete" do should "show the percent complete" do
@response.body = @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", /30%/ assert_select "div.task.label", /30%/
end end
end end
end end
should "have an issue tooltip" do should "have an issue tooltip" do
@response.body = @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