diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb index 2ccadddbfd..576448171e 100644 --- a/features/step_definitions/common_steps.rb +++ b/features/step_definitions/common_steps.rb @@ -63,7 +63,7 @@ Given /^the [pP]roject(?: "([^\"]+?)")? uses the following types:$/ do |project, end Then(/^I should see the following fields:$/) do |table| - table.rows.each do |field, value| + table.raw.each do |field, value| # enforce matches including the value only if it is provided # i.e. the column in the table is created diff --git a/features/step_definitions/custom_field_steps.rb b/features/step_definitions/custom_field_steps.rb index e989698f26..8c27683971 100644 --- a/features/step_definitions/custom_field_steps.rb +++ b/features/step_definitions/custom_field_steps.rb @@ -64,7 +64,19 @@ Given /^the work package "(.+?)" has the custom field "(.+?)" set to "(.+?)"$/ d wp = InstanceFinder.find(WorkPackage, wp_name) custom_field = InstanceFinder.find(WorkPackageCustomField, field_name) - wp.custom_values.build(:custom_field => custom_field, :value => value) + set = false + + 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 + wp.custom_values.build(:custom_field => custom_field, :value => value) + end + wp.save! end diff --git a/features/work_packages/editable_fields.feature b/features/work_packages/editable_fields.feature index 799465f173..ecb12eface 100644 --- a/features/work_packages/editable_fields.feature +++ b/features/work_packages/editable_fields.feature @@ -68,7 +68,7 @@ Feature: Fields editable on work package edit And I follow "More" Then I should see the following fields: - | Type | Phase1 | + | Type | Phase | | Subject | pe1 | | Description | pe1 description | | Priority | prio1 | @@ -109,17 +109,24 @@ Feature: Fields editable on work package edit Given the role "manager" may have the following rights: | edit_work_packages | - Given the following work package custom fields are defined: + And there are the following types: + | Name | + | Phase | + And the project "ecookbook" has the following types: + | name | position | + | Phase | 1 | + And the following work package custom fields are defined: | name | type | | cf1 | int | + And the custom field "cf1" is activated for type "Phase" And there are the following work packages in project "ecookbook": - | subject | - | pe1 | + | subject | type | + | pe1 | Phase | And the work package "pe1" has the custom field "cf1" set to "4" When I go to the edit page of the work package called "pe1" Then I should see the following fields: - | cf1 | 4 | + | cf1 | 4 | \ No newline at end of file