Project

General

Profile

Patch #3195 » 0001-allow-start-date-of-a-issue-to-be-the-latest-due-dat.patch

Marius BĂLTEANU, 2018-05-18 22:00

View differences:

app/models/issue_relation.rb
190 190
  def successor_soonest_start
191 191
    if (TYPE_PRECEDES == self.relation_type) && delay && issue_from &&
192 192
           (issue_from.start_date || issue_from.due_date)
193
      add_working_days((issue_from.due_date || issue_from.start_date), (1 + delay))
193
      add_working_days((issue_from.due_date || issue_from.start_date), delay)
194 194
    end
195 195
  end
196 196

  
test/unit/issue_test.rb
2083 2083
      issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
2084 2084
      IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
2085 2085
                            :relation_type => IssueRelation::TYPE_PRECEDES)
2086
      assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
2086
      assert_equal Date.parse('2012-10-17'), issue2.reload.start_date
2087 2087

  
2088 2088
      issue1.reload
2089 2089
      issue1.due_date = '2012-10-23'
2090 2090
      issue1.save!
2091 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
2092

  
2093
      assert_equal Date.parse('2012-10-23'), issue2.start_date
2094
      assert_equal Date.parse('2012-10-25'), issue2.due_date
2094 2095
    end
2095 2096

  
2096 2097
    # The delay should honor non-working week days
......
2100 2101
      IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
2101 2102
                            :relation_type => IssueRelation::TYPE_PRECEDES,
2102 2103
                            :delay => 8)
2103
      assert_equal Date.parse('2014-03-25'), issue2.reload.start_date
2104
      assert_equal Date.parse('2014-03-24'), issue2.reload.start_date
2104 2105
    end
2105 2106
  end
2106 2107

  
......
2109 2110
    issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
2110 2111
    IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
2111 2112
                          :relation_type => IssueRelation::TYPE_PRECEDES)
2112
    assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
2113
    assert_equal Date.parse('2012-10-17'), issue2.reload.start_date
2113 2114

  
2114 2115
    issue1.reload
2115 2116
    issue1.start_date = '2012-09-17'
2116
    issue1.due_date = '2012-09-18'
2117
    issue1.due_date = '2012-09-17'
2117 2118
    issue1.save!
2118 2119
    issue2.reload
2119
    assert_equal Date.parse('2012-09-19'), issue2.start_date
2120
    assert_equal Date.parse('2012-09-21'), issue2.due_date
2120
    assert_equal Date.parse('2012-09-17'), issue2.start_date
2121
    assert_equal Date.parse('2012-09-19'), issue2.due_date
2121 2122
  end
2122 2123

  
2123 2124
  def test_rescheduling_reschedule_following_issue_earlier_should_consider_other_preceding_issues
......
2128 2129
                          :relation_type => IssueRelation::TYPE_PRECEDES)
2129 2130
    IssueRelation.create!(:issue_from => issue3, :issue_to => issue2,
2130 2131
                          :relation_type => IssueRelation::TYPE_PRECEDES)
2131
    assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
2132
    assert_equal Date.parse('2012-10-17'), issue2.reload.start_date
2132 2133

  
2133 2134
    issue1.reload
2134 2135
    issue1.start_date = '2012-09-17'
2135
    issue1.due_date = '2012-09-18'
2136
    issue1.due_date = '2012-09-17'
2136 2137
    issue1.save!
2137 2138
    issue2.reload
2138 2139
    # Issue 2 must start after Issue 3
2139
    assert_equal Date.parse('2012-10-03'), issue2.start_date
2140
    assert_equal Date.parse('2012-10-05'), issue2.due_date
2140
    assert_equal Date.parse('2012-10-02'), issue2.start_date
2141
    assert_equal Date.parse('2012-10-04'), issue2.due_date
2141 2142
  end
2142 2143

  
2143 2144
  def test_rescheduling_a_stale_issue_should_not_raise_an_error
......
2162 2163
                          :relation_type => IssueRelation::TYPE_PRECEDES)
2163 2164
    issue1.reload
2164 2165
    issue2.reload
2165
    assert_equal Date.parse('2012-10-18'), issue2.start_date
2166
    assert_equal Date.parse('2012-10-17'), issue2.start_date
2166 2167

  
2167 2168
    with_settings :date_format => '%m/%d/%Y' do
2168 2169
      child = Issue.new(:parent_issue_id => issue2.id, :start_date => '2012-10-16',
2169 2170
        :project_id => 1, :tracker_id => 1, :status_id => 1, :subject => 'Child', :author_id => 1)
2170 2171
      assert !child.valid?
2171
      assert_include 'Start date cannot be earlier than 10/18/2012 because of preceding issues', child.errors.full_messages
2172
      assert_equal Date.parse('2012-10-18'), child.soonest_start
2173
      child.start_date = '2012-10-18'
2172
      assert_include 'Start date cannot be earlier than 10/17/2012 because of preceding issues', child.errors.full_messages
2173
      assert_equal Date.parse('2012-10-17'), child.soonest_start
2174
      child.start_date = '2012-10-17'
2174 2175
      assert child.save
2175 2176
    end
2176 2177
  end
......
3094 3095
    # March 21st and the issue should be marked overdue
3095 3096
    User.current = user_in_asia
3096 3097
    assert issue.overdue?
3097

  
3098 3098
  end
3099

  
3099 3100
end
(2-2/7)