]> source.dussan.org Git - redmine.git/commitdiff
Merged r11640 from trunk (#12968).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 19 Mar 2013 18:37:33 +0000 (18:37 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 19 Mar 2013 18:37:33 +0000 (18:37 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.3-stable@11655 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
test/unit/issue_test.rb

index cc50637e008d64b0274de6e5a5a9aaf5477cf144..ec108a01668c7220b6604d451fae8d374cecae8d 100644 (file)
@@ -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
 
index 1f8ecba09d3e547b050f4c0cb9df8451d38dee26..d0f44140bd7e7186da9f211746339274c539898a 100644 (file)
@@ -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?