Project

General

Profile

Defect #33175 » 33175.patch

Yuichi HARADA, 2020-03-19 04:16

View differences:

lib/redmine/helpers/gantt.rb
624 624
        zoom ||= @zoom
625 625
        coords = {}
626 626
        if start_date && end_date && start_date < self.date_to && end_date > self.date_from
627
          if start_date > self.date_from
627
          if start_date >= self.date_from
628 628
            coords[:start] = start_date - self.date_from
629 629
            coords[:bar_start] = start_date - self.date_from
630 630
          else
631 631
            coords[:bar_start] = 0
632 632
          end
633
          if end_date < self.date_to
633
          if end_date <= self.date_to
634 634
            coords[:end] = end_date - self.date_from
635 635
            coords[:bar_end] = end_date - self.date_from + 1
636 636
          else
test/unit/lib/redmine/helpers/gantt_test.rb
44 44
  def gantt_start
45 45
    @gantt.date_from
46 46
  end
47
  private :gantt_start
48

  
49
  def gantt_end
50
    @gantt.date_to
51
  end
52
  private :gantt_end
47 53

  
48 54
  # Creates a Gantt chart for a 4 week span
49 55
  def create_gantt(project=Project.generate!, options={})
......
422 428
  test "#line starting marker should appear at the start date" do
423 429
    create_gantt
424 430
    @output_buffer = @gantt.line(today - 7, today + 7, 30, true, 'line', :format => :html, :zoom => 4)
425
    assert_select "div.starting", 1
426 431
    assert_select 'div.starting[style*="left:28px"]', 1
432
    @output_buffer = @gantt.line(gantt_start, today + 7, 30, true, 'line', :format => :html, :zoom => 4)
433
    assert_select 'div.starting[style*="left:0px"]', 1
427 434
  end
428 435

  
429 436
  test "#line starting marker should not appear if the start date is before gantt start date" do
......
435 442
  test "#line ending marker should appear at the end date" do
436 443
    create_gantt
437 444
    @output_buffer = @gantt.line(today - 7, today + 7, 30, true, 'line', :format => :html, :zoom => 4)
438
    assert_select "div.ending", 1
439 445
    assert_select 'div.ending[style*="left:88px"]', 1
446
    @output_buffer = @gantt.line(today - 7, gantt_end, 30, true, 'line', :format => :html, :zoom => 4)
447
    assert_select 'div.ending[style*="left:116px"]', 1
440 448
  end
441 449

  
442 450
  test "#line ending marker should not appear if the end date is before gantt start date" do
(3-3/4)