From f98f9b9ae14a14b18838fd54d75f3676f41b5c61 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 19 Mar 2013 18:37:33 +0000 Subject: [PATCH] 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 --- app/models/issue.rb | 2 +- test/unit/issue_test.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index cc50637e0..ec108a016 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -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 diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 1f8ecba09..d0f44140b 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -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?