add-due-date-update-to-following-journal.diff

Kevin Fischer, 2018-04-27 07:43

Download (2.52 KB)

View differences:

app/models/issue.rb
1308 1308
          # Issue can not be moved earlier than its soonest start date
1309 1309
          date = [soonest_start(true), date].compact.max
1310 1310
        end
1311
        init_journal(User.current)
1311 1312
        reschedule_on(date)
1312 1313
        begin
1313 1314
          save
test/unit/issue_test.rb
2089 2089
    assert_equal Date.parse('2012-09-21'), issue2.due_date
2090 2090
  end
2091 2091

  
2092
  def test_rescheduling_an_issue_to_a_different_due_date_should_add_journal_to_following_issue
2093
    with_settings :non_working_week_days => [] do
2094
      issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
2095
      issue2 = Issue.generate!(:start_date => '2012-10-18', :due_date => '2012-10-20')
2096
      IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
2097
                            :relation_type => IssueRelation::TYPE_PRECEDES)
2098

  
2099
      issue2_journal_size_before = issue2.reload.journals.size
2100

  
2101
      issue1.reload
2102
      issue1.update!(:due_date => '2012-10-23')
2103
      issue2.reload
2104

  
2105
      assert_equal issue2_journal_size_before + 1, issue2.journals.size
2106

  
2107
      start_date_detail = issue2.journals.last.details.find_by(:prop_key => 'start_date')
2108
      assert_equal '2012-10-18', start_date_detail.old_value
2109
      assert_equal '2012-10-24', start_date_detail.value
2110

  
2111
      due_date_detail = issue2.journals.last.details.find_by(:prop_key => 'due_date')
2112
      assert_equal '2012-10-20', due_date_detail.old_value
2113
      assert_equal '2012-10-26', due_date_detail.value
2114
    end
2115
  end
2116

  
2117

  
2092 2118
  def test_rescheduling_reschedule_following_issue_earlier_should_consider_other_preceding_issues
2093 2119
    issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
2094 2120
    issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
2095
-