From: Go MAEDA Date: Sat, 25 Jul 2020 08:55:25 +0000 (+0000) Subject: Merged r19935 from trunk to 4.0-stable (#33140). X-Git-Tag: 4.0.8~23 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1f501b7b74bf8923ddd106315342f01cb8404e3f;p=redmine.git Merged r19935 from trunk to 4.0-stable (#33140). git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@19937 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index b78fe6664..92cc57c96 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -573,7 +573,7 @@ module Redmine def coordinates(start_date, end_date, progress, zoom=nil) zoom ||= @zoom coords = {} - if start_date && end_date && start_date < self.date_to && end_date > self.date_from + if start_date && end_date && start_date <= self.date_to && end_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 diff --git a/test/unit/lib/redmine/helpers/gantt_test.rb b/test/unit/lib/redmine/helpers/gantt_test.rb index 351f9c037..0067f4e2c 100644 --- a/test/unit/lib/redmine/helpers/gantt_test.rb +++ b/test/unit/lib/redmine/helpers/gantt_test.rb @@ -39,6 +39,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={}) @@ -335,6 +341,26 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest assert_select 'div.task_todo[style*="left:28px"]', 1 end + test "#line todo line should appear if it ends on the leftmost date in the gantt" do + create_gantt + [gantt_start - 1, gantt_start].each do |start_date| + @output_buffer = @gantt.line(start_date, gantt_start, 30, false, 'line', :format => :html, :zoom => 4) + # the leftmost date (Date.today - 14 days) + assert_select 'div.task_todo[style*="left:0px"]', 1, @output_buffer + assert_select 'div.task_todo[style*="width:2px"]', 1, @output_buffer + end + end + + test "#line todo line should appear if it starts on the rightmost date in the gantt" do + create_gantt + [gantt_end, gantt_end + 1].each do |end_date| + @output_buffer = @gantt.line(gantt_end, end_date, 30, false, 'line', :format => :html, :zoom => 4) + # the rightmost date (Date.today + 14 days) + assert_select 'div.task_todo[style*="left:112px"]', 1, @output_buffer + assert_select 'div.task_todo[style*="width:2px"]', 1, @output_buffer + end + end + test "#line todo line should be the total width" do create_gantt @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)