##// END OF EJS Templates
Precede-Follow relation should move following issues earlier when rescheduling issue earlier (#4590)....
Jean-Philippe Lang -
r10651:b94c971755ec
parent child
Show More
@@ -869,9 +869,10 class Issue < ActiveRecord::Base
869 (start_date && due_date) ? working_days(start_date, due_date) : 0
869 (start_date && due_date) ? working_days(start_date, due_date) : 0
870 end
870 end
871
871
872 def soonest_start
872 def soonest_start(reload=false)
873 @soonest_start = nil if reload
873 @soonest_start ||= (
874 @soonest_start ||= (
874 relations_to.collect{|relation| relation.successor_soonest_start} +
875 relations_to(reload).collect{|relation| relation.successor_soonest_start} +
875 ancestors.collect(&:soonest_start)
876 ancestors.collect(&:soonest_start)
876 ).compact.max
877 ).compact.max
877 end
878 end
@@ -890,7 +891,11 class Issue < ActiveRecord::Base
890 def reschedule_on!(date)
891 def reschedule_on!(date)
891 return if date.nil?
892 return if date.nil?
892 if leaf?
893 if leaf?
893 if start_date.nil? || start_date < date
894 if start_date.nil? || start_date != date
895 if start_date && start_date > date
896 # Issue can not be moved earlier than its soonest start date
897 date = [soonest_start(true), date].compact.max
898 end
894 reschedule_on(date)
899 reschedule_on(date)
895 begin
900 begin
896 save
901 save
@@ -1363,7 +1363,7 class IssueTest < ActiveSupport::TestCase
1363 end
1363 end
1364 end
1364 end
1365
1365
1366 def test_rescheduling_an_issue_should_reschedule_following_issue
1366 def test_rescheduling_an_issue_to_a_later_due_date_should_reschedule_following_issue
1367 issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1367 issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1368 issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1368 issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1369 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
1369 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
@@ -1377,6 +1377,40 class IssueTest < ActiveSupport::TestCase
1377 assert_equal Date.parse('2012-10-26'), issue2.due_date
1377 assert_equal Date.parse('2012-10-26'), issue2.due_date
1378 end
1378 end
1379
1379
1380 def test_rescheduling_an_issue_to_an_earlier_due_date_should_reschedule_following_issue
1381 issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1382 issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1383 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
1384 :relation_type => IssueRelation::TYPE_PRECEDES)
1385 assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
1386
1387 issue1.start_date = '2012-09-17'
1388 issue1.due_date = '2012-09-18'
1389 issue1.save!
1390 issue2.reload
1391 assert_equal Date.parse('2012-09-19'), issue2.start_date
1392 assert_equal Date.parse('2012-09-21'), issue2.due_date
1393 end
1394
1395 def test_rescheduling_reschedule_following_issue_earlier_should_consider_other_preceding_issues
1396 issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1397 issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
1398 issue3 = Issue.generate!(:start_date => '2012-10-01', :due_date => '2012-10-02')
1399 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
1400 :relation_type => IssueRelation::TYPE_PRECEDES)
1401 IssueRelation.create!(:issue_from => issue3, :issue_to => issue2,
1402 :relation_type => IssueRelation::TYPE_PRECEDES)
1403 assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
1404
1405 issue1.start_date = '2012-09-17'
1406 issue1.due_date = '2012-09-18'
1407 issue1.save!
1408 issue2.reload
1409 # Issue 2 must start after Issue 3
1410 assert_equal Date.parse('2012-10-03'), issue2.start_date
1411 assert_equal Date.parse('2012-10-05'), issue2.due_date
1412 end
1413
1380 def test_rescheduling_a_stale_issue_should_not_raise_an_error
1414 def test_rescheduling_a_stale_issue_should_not_raise_an_error
1381 with_settings :non_working_week_days => [] do
1415 with_settings :non_working_week_days => [] do
1382 stale = Issue.find(1)
1416 stale = Issue.find(1)
General Comments 0
You need to be logged in to leave comments. Login now