diff --git a/features/step_definitions/custom_field_steps.rb b/features/step_definitions/custom_field_steps.rb index cb43eefd04..d6badb240b 100644 --- a/features/step_definitions/custom_field_steps.rb +++ b/features/step_definitions/custom_field_steps.rb @@ -64,16 +64,11 @@ Given /^the work package "(.+?)" has the custom field "(.+?)" set to "(.+?)"$/ d wp = InstanceFinder.find(WorkPackage, wp_name) custom_field = InstanceFinder.find(WorkPackageCustomField, field_name) - set = false + custom_value = wp.custom_values.detect {|cv| cv.custom_field_id == custom_field.id} - wp.custom_values.each do |custom_value| - if custom_value.custom_field_id == custom_field.id then - set = true - custom_value.value = value - end - end - - if !set then + if custom_value + custom_value.value = value + else wp.custom_values.build(:custom_field => custom_field, :value => value) end