]> source.dussan.org Git - redmine.git/commitdiff
Merged r15857 (#23878).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 2 Oct 2016 10:21:45 +0000 (10:21 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 2 Oct 2016 10:21:45 +0000 (10:21 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@15876 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 3f963a08a7e09e6c9a04cca412773813add452e4..1b9f216316ecdd8f49c6bbcdc3aac46e9e5c542b 100644 (file)
@@ -1534,10 +1534,11 @@ class Issue < ActiveRecord::Base
     if issue_id && p = Issue.find_by_id(issue_id)
       if p.priority_derived?
         # priority = highest priority of open children
+        # priority is left unchanged if all children are closed and there's no default priority defined
         if priority_position = p.children.open.joins(:priority).maximum("#{IssuePriority.table_name}.position")
           p.priority = IssuePriority.find_by_position(priority_position)
-        else
-          p.priority = IssuePriority.default
+        elsif default_priority = IssuePriority.default
+          p.priority = default_priority
         end
       end
 
index 189c6988ce22f0c08128f4b4d5e82cbac242f747..44137dbef1244e546e192415ce18c9890ba363ce 100644 (file)
@@ -108,6 +108,30 @@ class IssueSubtaskingTest < ActiveSupport::TestCase
     end
   end
 
+  def test_parent_priority_should_be_set_to_default_when_all_children_are_closed
+    with_settings :parent_issue_priority => 'derived' do
+      parent = Issue.generate!
+      child = parent.generate_child!(:priority => IssuePriority.find_by_name('High'))
+      assert_equal 'High', parent.reload.priority.name
+      child.status = IssueStatus.where(:is_closed => true).first
+      child.save!
+      assert_equal 'Normal', parent.reload.priority.name
+    end
+  end
+
+  def test_parent_priority_should_be_left_unchanged_when_all_children_are_closed_and_no_default_priority
+    IssuePriority.update_all :is_default => false
+
+    with_settings :parent_issue_priority => 'derived' do
+      parent = Issue.generate!(:priority => IssuePriority.find_by_name('Normal'))
+      child = parent.generate_child!(:priority => IssuePriority.find_by_name('High'))
+      assert_equal 'High', parent.reload.priority.name
+      child.status = IssueStatus.where(:is_closed => true).first
+      child.save!
+      assert_equal 'High', parent.reload.priority.name
+    end
+  end
+
   def test_parent_done_ratio_should_be_read_only_with_parent_issue_done_ratio_set_to_derived
     with_settings :parent_issue_done_ratio => 'derived' do
       issue = Issue.generate_with_child!