Merged r11640 from trunk (#12968).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.3-stable@11655 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
cfec2018e3
commit
f98f9b9ae1
|
@ -892,7 +892,7 @@ class Issue < ActiveRecord::Base
|
|||
@soonest_start = nil if reload
|
||||
@soonest_start ||= (
|
||||
relations_to(reload).collect{|relation| relation.successor_soonest_start} +
|
||||
ancestors.collect(&:soonest_start)
|
||||
[(@parent_issue || parent).try(:soonest_start)]
|
||||
).compact.max
|
||||
end
|
||||
|
||||
|
|
|
@ -1509,6 +1509,25 @@ class IssueTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_child_issue_should_consider_parent_soonest_start_on_create
|
||||
set_language_if_valid 'en'
|
||||
issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||
issue2 = Issue.generate!(:start_date => '2012-10-18', :due_date => '2012-10-20')
|
||||
IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
|
||||
:relation_type => IssueRelation::TYPE_PRECEDES)
|
||||
issue1.reload
|
||||
issue2.reload
|
||||
assert_equal Date.parse('2012-10-18'), issue2.start_date
|
||||
|
||||
child = Issue.new(:parent_issue_id => issue2.id, :start_date => '2012-10-16',
|
||||
:project_id => 1, :tracker_id => 1, :status_id => 1, :subject => 'Child', :author_id => 1)
|
||||
assert !child.valid?
|
||||
assert_include 'Start date is invalid', child.errors.full_messages
|
||||
assert_equal Date.parse('2012-10-18'), child.soonest_start
|
||||
child.start_date = '2012-10-18'
|
||||
assert child.save
|
||||
end
|
||||
|
||||
def test_overdue
|
||||
assert Issue.new(:due_date => 1.day.ago.to_date).overdue?
|
||||
assert !Issue.new(:due_date => Date.today).overdue?
|
||||
|
|
Loading…
Reference in New Issue