diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index 285eb66a0..ad9bab8ad 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -624,13 +624,13 @@ module Redmine zoom ||= @zoom coords = {} if start_date && end_date && start_date < self.date_to && end_date > self.date_from - if start_date > self.date_from + if start_date >= self.date_from coords[:start] = start_date - self.date_from coords[:bar_start] = start_date - self.date_from else coords[:bar_start] = 0 end - if end_date < self.date_to + if end_date <= self.date_to coords[:end] = end_date - self.date_from coords[:bar_end] = end_date - self.date_from + 1 else diff --git a/test/unit/lib/redmine/helpers/gantt_test.rb b/test/unit/lib/redmine/helpers/gantt_test.rb index 3e45735ef..5ab49f69f 100644 --- a/test/unit/lib/redmine/helpers/gantt_test.rb +++ b/test/unit/lib/redmine/helpers/gantt_test.rb @@ -44,6 +44,12 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest def gantt_start @gantt.date_from end + private :gantt_start + + def gantt_end + @gantt.date_to + end + private :gantt_end # Creates a Gantt chart for a 4 week span def create_gantt(project=Project.generate!, options={}) @@ -422,8 +428,9 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest 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 + @output_buffer = @gantt.line(gantt_start, today + 7, 30, true, 'line', :format => :html, :zoom => 4) + assert_select 'div.starting[style*="left:0px"]', 1 end test "#line starting marker should not appear if the start date is before gantt start date" do @@ -435,8 +442,9 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest 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 + @output_buffer = @gantt.line(today - 7, gantt_end, 30, true, 'line', :format => :html, :zoom => 4) + assert_select 'div.ending[style*="left:116px"]', 1 end test "#line ending marker should not appear if the end date is before gantt start date" do