From 5663c075809837573e492b49ea46d1742f2f0de9 Mon Sep 17 00:00:00 2001 From: Jan Sandbrink Date: Wed, 18 Mar 2015 15:16:40 +0100 Subject: [PATCH] fix cost_object validation - would not work for invalid ids - use "inclusion" message instead of generic "invalid" message --- lib/open_project/costs/patches/work_package_patch.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/open_project/costs/patches/work_package_patch.rb b/lib/open_project/costs/patches/work_package_patch.rb index 2b08d59e91..6f425ee3ac 100644 --- a/lib/open_project/costs/patches/work_package_patch.rb +++ b/lib/open_project/costs/patches/work_package_patch.rb @@ -99,9 +99,9 @@ module OpenProject::Costs::Patches::WorkPackagePatch end def validate_cost_object - if cost_object && cost_object.changed? - unless (cost_object.blank? || project.cost_object_ids.include?(cost_object.id)) - errors.add :cost_object, :invalid + if changed.include? 'cost_object_id' + unless (cost_object_id.blank? || project.cost_object_ids.include?(cost_object_id)) + errors.add :cost_object, :inclusion end end end