diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-12-21 09:09:22 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-12-21 09:09:22 +0000 |
commit | f3627e2a3d1a9fa606fc71f66776d4b879b92323 (patch) | |
tree | 4a417801393a9e68a7cccef954317a839227254b /app/models | |
parent | 3d1f72bc509e2fc8fc55e0ece3c3e230910d07c4 (diff) | |
download | redmine-f3627e2a3d1a9fa606fc71f66776d4b879b92323.tar.gz redmine-f3627e2a3d1a9fa606fc71f66776d4b879b92323.zip |
Prevent parent issue from being closed if a child issue is open (#10989).
git-svn-id: http://svn.redmine.org/redmine/trunk@16108 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/issue.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index b515c4a74..65d0784ad 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -723,6 +723,9 @@ class Issue < ActiveRecord::Base @parent_issue.self_and_ancestors.any? {|a| a.relations_from.any? {|r| r.relation_type == IssueRelation::TYPE_PRECEDES && r.issue_to.would_reschedule?(self)}} ) errors.add :parent_issue_id, :invalid + elsif !closed? && @parent_issue.closed? + # cannot attach an open issue to a closed parent + errors.add :base, :open_issue_with_closed_parent elsif !new_record? # moving an existing issue if move_possible?(@parent_issue) @@ -945,9 +948,14 @@ class Issue < ActiveRecord::Base end statuses = statuses.compact.uniq.sort - if blocked? + if blocked? || descendants.open.any? + # cannot close a blocked issue or a parent with open subtasks statuses.reject!(&:is_closed?) end + if ancestors.open(false).any? + # cannot reopen a subtask of a closed parent + statuses.select!(&:is_closed?) + end statuses end |