Project

General

Profile

Defect #14846 » 14846-r17212.patch

patch for r17212 - Go MAEDA, 2018-02-26 10:42

View differences:

app/models/issue_relation.rb
31 31
  end
32 32

  
33 33
  include Redmine::SafeAttributes
34
  include Redmine::Utils::DateCalculation
34 35

  
35 36
  belongs_to :issue_from, :class_name => 'Issue'
36 37
  belongs_to :issue_to, :class_name => 'Issue'
......
189 190
  def successor_soonest_start
190 191
    if (TYPE_PRECEDES == self.relation_type) && delay && issue_from &&
191 192
           (issue_from.start_date || issue_from.due_date)
192
      (issue_from.due_date || issue_from.start_date) + 1 + delay
193
      add_working_days((issue_from.due_date || issue_from.start_date), (1 + delay))
193 194
    end
194 195
  end
195 196

  
test/unit/issue_test.rb
2078 2078
  end
2079 2079

  
2080 2080
  def test_rescheduling_an_issue_to_a_later_due_date_should_reschedule_following_issue
2081
    issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
2082
    issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
2083
    IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
2084
                          :relation_type => IssueRelation::TYPE_PRECEDES)
2085
    assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
2081
    with_settings :non_working_week_days => [] do
2082
      issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
2083
      issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
2084
      IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
2085
                            :relation_type => IssueRelation::TYPE_PRECEDES)
2086
      assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
2087

  
2088
      issue1.reload
2089
      issue1.due_date = '2012-10-23'
2090
      issue1.save!
2091
      issue2.reload
2092
      assert_equal Date.parse('2012-10-24'), issue2.start_date
2093
      assert_equal Date.parse('2012-10-26'), issue2.due_date
2094
    end
2086 2095

  
2087
    issue1.reload
2088
    issue1.due_date = '2012-10-23'
2089
    issue1.save!
2090
    issue2.reload
2091
    assert_equal Date.parse('2012-10-24'), issue2.start_date
2092
    assert_equal Date.parse('2012-10-26'), issue2.due_date
2096
    # The delay should honor non-working week days
2097
    with_settings :non_working_week_days => %w(6 7) do
2098
      issue1 = Issue.generate!(:start_date => '2014-03-10', :due_date => '2014-03-12')
2099
      issue2 = Issue.generate!(:start_date => '2014-03-10', :due_date => '2014-03-12')
2100
      IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
2101
                            :relation_type => IssueRelation::TYPE_PRECEDES,
2102
                            :delay => 8)
2103
      assert_equal Date.parse('2014-03-25'), issue2.reload.start_date
2104
    end
2093 2105
  end
2094 2106

  
2095 2107
  def test_rescheduling_an_issue_to_an_earlier_due_date_should_reschedule_following_issue
(2-2/2)