diff options
Diffstat (limited to 'app/models/work_items/parent_link.rb')
-rw-r--r-- | app/models/work_items/parent_link.rb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/app/models/work_items/parent_link.rb b/app/models/work_items/parent_link.rb index ea7755b03b4..32232c93d11 100644 --- a/app/models/work_items/parent_link.rb +++ b/app/models/work_items/parent_link.rb @@ -15,7 +15,6 @@ module WorkItems validates :work_item, presence: true, uniqueness: true validate :validate_hierarchy_restrictions validate :validate_cyclic_reference - validate :validate_same_project validate :validate_max_children validate :validate_confidentiality validate :check_existing_related_link @@ -50,14 +49,6 @@ module WorkItems private - def validate_same_project - return if work_item.nil? || work_item_parent.nil? - - if work_item.resource_parent != work_item_parent.resource_parent - errors.add :work_item_parent, _('parent must be in the same project as child.') - end - end - def validate_max_children return unless work_item_parent @@ -88,6 +79,14 @@ module WorkItems end validate_depth(restriction.maximum_depth) + validate_cross_hierarchy(restriction.cross_hierarchy_enabled) + end + + def validate_cross_hierarchy(cross_hierarchy_enabled) + return if cross_hierarchy_enabled + return if work_item.resource_parent == work_item_parent.resource_parent + + errors.add :work_item_parent, _('parent must be in the same project or group as child.') end def validate_depth(depth) |