Commit d41c494d authored by maeda's avatar maeda

Fix: Calculation of the start date of following issues ignores the...

Fix: Calculation of the start date of following issues ignores the "non-working days" setting (#14846).

Patch by Felix Schäfer.


git-svn-id: https://svn.redmine.org/redmine/trunk@17230 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 8ac01737
......@@ -31,6 +31,7 @@ class IssueRelation < ActiveRecord::Base
end
include Redmine::SafeAttributes
include Redmine::Utils::DateCalculation
belongs_to :issue_from, :class_name => 'Issue'
belongs_to :issue_to, :class_name => 'Issue'
......@@ -189,7 +190,7 @@ class IssueRelation < ActiveRecord::Base
def successor_soonest_start
if (TYPE_PRECEDES == self.relation_type) && delay && issue_from &&
(issue_from.start_date || issue_from.due_date)
(issue_from.due_date || issue_from.start_date) + 1 + delay
add_working_days((issue_from.due_date || issue_from.start_date), (1 + delay))
end
end
......
......@@ -2078,18 +2078,30 @@ class IssueTest < ActiveSupport::TestCase
end
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')
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
with_settings :non_working_week_days => [] do
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.reload
issue1.due_date = '2012-10-23'
issue1.save!
issue2.reload
assert_equal Date.parse('2012-10-24'), issue2.start_date
assert_equal Date.parse('2012-10-26'), issue2.due_date
end
issue1.reload
issue1.due_date = '2012-10-23'
issue1.save!
issue2.reload
assert_equal Date.parse('2012-10-24'), issue2.start_date
assert_equal Date.parse('2012-10-26'), issue2.due_date
# The delay should honor non-working week days
with_settings :non_working_week_days => %w(6 7) do
issue1 = Issue.generate!(:start_date => '2014-03-10', :due_date => '2014-03-12')
issue2 = Issue.generate!(:start_date => '2014-03-10', :due_date => '2014-03-12')
IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
:relation_type => IssueRelation::TYPE_PRECEDES,
:delay => 8)
assert_equal Date.parse('2014-03-25'), issue2.reload.start_date
end
end
def test_rescheduling_an_issue_to_an_earlier_due_date_should_reschedule_following_issue
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment