Precede-Follow relation should move following issues earlier when rescheduling issue earlier (#4590).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10878 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
29fc292b18
commit
b94c971755
|
@ -869,9 +869,10 @@ class Issue < ActiveRecord::Base
|
||||||
(start_date && due_date) ? working_days(start_date, due_date) : 0
|
(start_date && due_date) ? working_days(start_date, due_date) : 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def soonest_start
|
def soonest_start(reload=false)
|
||||||
|
@soonest_start = nil if reload
|
||||||
@soonest_start ||= (
|
@soonest_start ||= (
|
||||||
relations_to.collect{|relation| relation.successor_soonest_start} +
|
relations_to(reload).collect{|relation| relation.successor_soonest_start} +
|
||||||
ancestors.collect(&:soonest_start)
|
ancestors.collect(&:soonest_start)
|
||||||
).compact.max
|
).compact.max
|
||||||
end
|
end
|
||||||
|
@ -890,7 +891,11 @@ class Issue < ActiveRecord::Base
|
||||||
def reschedule_on!(date)
|
def reschedule_on!(date)
|
||||||
return if date.nil?
|
return if date.nil?
|
||||||
if leaf?
|
if leaf?
|
||||||
if start_date.nil? || start_date < date
|
if start_date.nil? || start_date != date
|
||||||
|
if start_date && start_date > date
|
||||||
|
# Issue can not be moved earlier than its soonest start date
|
||||||
|
date = [soonest_start(true), date].compact.max
|
||||||
|
end
|
||||||
reschedule_on(date)
|
reschedule_on(date)
|
||||||
begin
|
begin
|
||||||
save
|
save
|
||||||
|
|
|
@ -1363,7 +1363,7 @@ class IssueTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rescheduling_an_issue_should_reschedule_following_issue
|
def test_rescheduling_an_issue_to_a_later_due_date_should_reschedule_following_issue
|
||||||
issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||||
issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||||
IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
|
IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
|
||||||
|
@ -1377,6 +1377,40 @@ class IssueTest < ActiveSupport::TestCase
|
||||||
assert_equal Date.parse('2012-10-26'), issue2.due_date
|
assert_equal Date.parse('2012-10-26'), issue2.due_date
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_rescheduling_an_issue_to_an_earlier_due_date_should_reschedule_following_issue
|
||||||
|
issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||||
|
issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||||
|
IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
|
||||||
|
:relation_type => IssueRelation::TYPE_PRECEDES)
|
||||||
|
assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
|
||||||
|
|
||||||
|
issue1.start_date = '2012-09-17'
|
||||||
|
issue1.due_date = '2012-09-18'
|
||||||
|
issue1.save!
|
||||||
|
issue2.reload
|
||||||
|
assert_equal Date.parse('2012-09-19'), issue2.start_date
|
||||||
|
assert_equal Date.parse('2012-09-21'), issue2.due_date
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_rescheduling_reschedule_following_issue_earlier_should_consider_other_preceding_issues
|
||||||
|
issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||||
|
issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||||
|
issue3 = Issue.generate!(:start_date => '2012-10-01', :due_date => '2012-10-02')
|
||||||
|
IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
|
||||||
|
:relation_type => IssueRelation::TYPE_PRECEDES)
|
||||||
|
IssueRelation.create!(:issue_from => issue3, :issue_to => issue2,
|
||||||
|
:relation_type => IssueRelation::TYPE_PRECEDES)
|
||||||
|
assert_equal Date.parse('2012-10-18'), issue2.reload.start_date
|
||||||
|
|
||||||
|
issue1.start_date = '2012-09-17'
|
||||||
|
issue1.due_date = '2012-09-18'
|
||||||
|
issue1.save!
|
||||||
|
issue2.reload
|
||||||
|
# Issue 2 must start after Issue 3
|
||||||
|
assert_equal Date.parse('2012-10-03'), issue2.start_date
|
||||||
|
assert_equal Date.parse('2012-10-05'), issue2.due_date
|
||||||
|
end
|
||||||
|
|
||||||
def test_rescheduling_a_stale_issue_should_not_raise_an_error
|
def test_rescheduling_a_stale_issue_should_not_raise_an_error
|
||||||
with_settings :non_working_week_days => [] do
|
with_settings :non_working_week_days => [] do
|
||||||
stale = Issue.find(1)
|
stale = Issue.find(1)
|
||||||
|
|
Loading…
Reference in New Issue