diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-01-16 09:00:37 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-01-16 09:00:37 +0000 |
commit | f4b2b7e7fb133d5b6beec9315cd456ba83a5fc79 (patch) | |
tree | da7434a105c7d57708ed25b22c3ae10dd7a759d4 | |
parent | b3663ee5c4bf093234d90ef81ea788d9433914ee (diff) | |
download | redmine-f4b2b7e7fb133d5b6beec9315cd456ba83a5fc79.tar.gz redmine-f4b2b7e7fb133d5b6beec9315cd456ba83a5fc79.zip |
Only consider open subtasks when computing the priority of a parent issue (#5880).
Patch by Go MAEDA.
git-svn-id: http://svn.redmine.org/redmine/trunk@15064 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/issue.rb | 6 | ||||
-rw-r--r-- | test/unit/issue_subtasking_test.rb | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 00a122c1b..cf9faaf33 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1451,9 +1451,11 @@ class Issue < ActiveRecord::Base def recalculate_attributes_for(issue_id) if issue_id && p = Issue.find_by_id(issue_id) if p.priority_derived? - # priority = highest priority of children - if priority_position = p.children.joins(:priority).maximum("#{IssuePriority.table_name}.position") + # priority = highest priority of open children + 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 end end diff --git a/test/unit/issue_subtasking_test.rb b/test/unit/issue_subtasking_test.rb index cadfe6644..184c9016c 100644 --- a/test/unit/issue_subtasking_test.rb +++ b/test/unit/issue_subtasking_test.rb @@ -78,7 +78,7 @@ class IssueSubtaskingTest < ActiveSupport::TestCase end end - def test_parent_priority_should_be_the_highest_child_priority + def test_parent_priority_should_be_the_highest_open_child_priority with_settings :parent_issue_priority => 'derived' do parent = Issue.generate!(:priority => IssuePriority.find_by_name('Normal')) # Create children @@ -88,14 +88,23 @@ class IssueSubtaskingTest < ActiveSupport::TestCase assert_equal 'Immediate', child1.reload.priority.name assert_equal 'Immediate', parent.reload.priority.name child3 = parent.generate_child!(:priority => IssuePriority.find_by_name('Low')) + child4 = parent.generate_child!(:priority => IssuePriority.find_by_name('Urgent')) assert_equal 'Immediate', parent.reload.priority.name # Destroy a child child1.destroy + assert_equal 'Urgent', parent.reload.priority.name + # Close a child + child4.status = IssueStatus.where(:is_closed => true).first + child4.save! assert_equal 'Low', parent.reload.priority.name # Update a child child3.reload.priority = IssuePriority.find_by_name('Normal') child3.save! assert_equal 'Normal', parent.reload.priority.name + # Reopen a child + child4.status = IssueStatus.where(:is_closed => false).first + child4.save! + assert_equal 'Urgent', parent.reload.priority.name end end |