From 60eb70b30e01cb0d9b3aa1efdf3c6ec59dc2d9ed Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 4 Dec 2014 14:57:58 +0100 Subject: [PATCH] Validate WP children Originially, this method was defined in a WP patch in OpenProject Backlogs. --- app/models/work_package/validations.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/work_package/validations.rb b/app/models/work_package/validations.rb index 4cf566e134..22979661c4 100644 --- a/app/models/work_package/validations.rb +++ b/app/models/work_package/validations.rb @@ -52,6 +52,8 @@ module WorkPackage::Validations validate :validate_status_transition validate :validate_active_priority + + validate :validate_children end def validate_start_date_before_soonest_start_date @@ -103,6 +105,14 @@ module WorkPackage::Validations end end + def validate_children + children.select { |c| !c.valid? }.each do |child| + child.errors.each do |_, value| + errors.add(:"##{child.id}", value) + end + end + end + private def status_changed?