OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
refactor: Rename and generalize #accessor_name as #attribute_name
Christophe Bliard10085736da14
diff --git a/app/contracts/base_contract.rb b/app/contracts/base_contract.rbindex a1386102c33..66906aa8214 100644--- a/app/contracts/base_contract.rb+++ b/app/contracts/base_contract.rb@@ -227,7 +227,7 @@ class BaseContract < Disposable::Twinendif model.respond_to?(:available_custom_fields)- writable += model.available_custom_fields.map { |cf| "custom_field_#{cf.id}" }+ writable += model.available_custom_fields.map(&:attribute_name)endwritablediff --git a/app/models/attribute_help_text/project.rb b/app/models/attribute_help_text/project.rbindex e38ac59e901..683e816a6b5 100644--- a/app/models/attribute_help_text/project.rb+++ b/app/models/attribute_help_text/project.rb@@ -35,8 +35,8 @@ class AttributeHelpText::Project < AttributeHelpText.reject { |key, _| skip.include?(key.to_s) }.transform_values { |definition| definition[:name_source].call }- ProjectCustomField.all.find_each do |field|- attributes["custom_field_#{field.id}"] = field.name+ ProjectCustomField.find_each do |field|+ attributes[field.attribute_name] = field.nameendattributesdiff --git a/app/models/custom_actions/actions/custom_field.rb b/app/models/custom_actions/actions/custom_field.rbindex fb5df156aba..acb4e58a4e1 100644--- a/app/models/custom_actions/actions/custom_field.rb+++ b/app/models/custom_actions/actions/custom_field.rb@@ -28,7 +28,7 @@class CustomActions::Actions::CustomField < CustomActions::Actions::Basedef self.key- :"custom_field_#{custom_field.id}"+ custom_field.attribute_name.to_symenddef self.custom_field@@ -44,7 +44,7 @@ class CustomActions::Actions::CustomField < CustomActions::Actions::Baseenddef apply(work_package)- work_package.send(:"#{custom_field.accessor_name}=", values) if work_package.respond_to?(:"#{custom_field.accessor_name}=")+ work_package.send(custom_field.attribute_setter, values) if work_package.respond_to?(custom_field.attribute_setter)enddef self.alldiff --git a/app/models/custom_actions/actions/strategies/custom_field.rb b/app/models/custom_actions/actions/strategies/custom_field.rbindex 2665ec4e4a1..72c8be113df 100644--- a/app/models/custom_actions/actions/strategies/custom_field.rb+++ b/app/models/custom_actions/actions/strategies/custom_field.rb@@ -28,7 +28,7 @@module CustomActions::Actions::Strategies::CustomFielddef apply(work_package)- work_package.send(:"#{custom_field.accessor_name}=", values) if work_package.respond_to?(:"#{custom_field.accessor_name}=")+ work_package.send(custom_field.attribute_setter, values) if work_package.respond_to?(custom_field.attribute_setter)enddelegate :required?, to: :custom_fielddiff --git a/app/models/custom_actions/actions/strategies/user_custom_field.rb b/app/models/custom_actions/actions/strategies/user_custom_field.rbindex 23eb010530a..e496bb9b7b6 100644--- a/app/models/custom_actions/actions/strategies/user_custom_field.rb+++ b/app/models/custom_actions/actions/strategies/user_custom_field.rb@@ -31,8 +31,8 @@ module CustomActions::Actions::Strategies::UserCustomFieldinclude ::CustomActions::Actions::Strategies::MeAssociateddef apply(work_package)- if work_package.respond_to?(:"#{custom_field.accessor_name}=")- work_package.send(:"#{custom_field.accessor_name}=", transformed_value(values.first))+ if work_package.respond_to?(custom_field.attribute_setter)+ work_package.send(custom_field.attribute_setter, transformed_value(values.first))endenddiff --git a/app/models/custom_field.rb b/app/models/custom_field.rbindex 737606d08a6..9e72d5833a0 100644--- a/app/models/custom_field.rb+++ b/app/models/custom_field.rb@@ -232,10 +232,18 @@ class CustomField < ApplicationRecordwhere(is_filter: true)end- def accessor_name+ def attribute_name"custom_field_#{id}"end+ def attribute_getter+ attribute_name.to_sym+ end++ def attribute_setter+ :"#{attribute_name}="+ end+def type_namenilend@@ -325,7 +333,7 @@ class CustomField < ApplicationRecorddef destroy_help_textAttributeHelpText- .where(attribute_name: "custom_field_#{id}")+ .where(attribute_name:).destroy_allendenddiff --git a/app/models/queries/filters/shared/custom_field_filter.rb b/app/models/queries/filters/shared/custom_field_filter.rbindex 54861a1a45e..826c1335246 100644--- a/app/models/queries/filters/shared/custom_field_filter.rb+++ b/app/models/queries/filters/shared/custom_field_filter.rb@@ -40,7 +40,7 @@ module Queries::Filters::Shared::CustomFieldFilterend##- # TODO this differs from CustomField#accessor_name for reasons I don't see,+ # TODO this differs from CustomField#attribute_name for reasons I don't see,# however this name will be persisted in queries so we can't just map one to the other.def custom_field_accessor(custom_field)"cf_#{custom_field.id}"diff --git a/app/models/type/attributes.rb b/app/models/type/attributes.rbindex 86d01d4f0e6..c2afe6c5425 100644--- a/app/models/type/attributes.rb+++ b/app/models/type/attributes.rb@@ -144,7 +144,7 @@ module Type::Attributesdef add_custom_fields_to_form_attributes(attributes)WorkPackageCustomField.includes(:custom_options).all.find_each do |field|- attributes["custom_field_#{field.id}"] = {+ attributes[field.attribute_name] = {required: field.is_required,has_default: field.default_value.present?,is_cf: true,diff --git a/app/seeders/development_data/custom_fields_seeder.rb b/app/seeders/development_data/custom_fields_seeder.rbindex 408259950ea..81e3627f1b5 100644--- a/app/seeders/development_data/custom_fields_seeder.rb+++ b/app/seeders/development_data/custom_fields_seeder.rb@@ -44,14 +44,14 @@ module DevelopmentDatadef create_types!(cfs)# Create ALL CFs types- non_req_cfs = cfs.reject(&:is_required).map { |cf| "custom_field_#{cf.id}" }+ non_req_cfs = cfs.reject(&:is_required).map(&:attribute_name)type = FactoryBot.build :type, name: 'All CFS'extend_group(type, ['Custom fields', non_req_cfs])type.save!print_status '.'# Create type- req_cfs = cfs.select(&:is_required).map { |cf| "custom_field_#{cf.id}" }+ req_cfs = cfs.select(&:is_required).map(&:attribute_name)type_req = FactoryBot.build :type, name: 'Required CF'extend_group(type_req, ['Custom fields', req_cfs])type_req.save!diff --git a/app/views/customizable/_form.html.erb b/app/views/customizable/_form.html.erbindex e78e10e5a33..cb357bc8459 100644--- a/app/views/customizable/_form.html.erb+++ b/app/views/customizable/_form.html.erb@@ -45,7 +45,7 @@ See COPYRIGHT and LICENSE files for more details.<% show_required = custom_field.is_required? && !custom_field.boolean? %><%= content_tag :div,class: ['form--field',- "custom_field_#{custom_field.id}",+ custom_field.attribute_name,(show_required ? '-required' : ''),wide_labels] dooptions = {diff --git a/lib/api/v3/utilities/custom_field_injector.rb b/lib/api/v3/utilities/custom_field_injector.rbindex e7d0bfef9f9..de76cab6934 100644--- a/lib/api/v3/utilities/custom_field_injector.rb+++ b/lib/api/v3/utilities/custom_field_injector.rb@@ -219,7 +219,7 @@ module API[value].compactend- represented.send(:"custom_field_#{custom_field.id}=", values)+ represented.send(custom_field.attribute_setter, values)}end@@ -233,7 +233,7 @@ module APIcustom_field.list? ||custom_field.multi_value?- value = represented.send custom_field.accessor_name+ value = represented.send custom_field.attribute_getternext unless value@@ -243,7 +243,7 @@ module APIenddef inject_property_value(custom_field)- @class.property "custom_field_#{custom_field.id}".to_sym,+ @class.property custom_field.attribute_name.to_sym,as: property_name(custom_field.id),getter: property_value_getter_for(custom_field),setter: property_value_setter_for(custom_field),@@ -254,7 +254,7 @@ module API->(*) {next unless available_custom_fields.include?(custom_field)- value = send custom_field.accessor_name+ value = send(custom_field.attribute_getter)if custom_field.field_format == 'text'::API::Decorators::Formattable.new(value, object: self)@@ -271,7 +271,7 @@ module APIelsefragmentend- send(:"custom_field_#{custom_field.id}=", value)+ send(custom_field.attribute_setter, value)}enddiff --git a/lib/custom_field_form_builder.rb b/lib/custom_field_form_builder.rbindex c746b76fffe..3bd3c99e11f 100644--- a/lib/custom_field_form_builder.rb+++ b/lib/custom_field_form_builder.rb@@ -58,7 +58,7 @@ class CustomFieldFormBuilder < TabularFormBuilderprivatedef custom_field_input(options = {})- field = custom_field.accessor_name+ field = custom_field.attribute_nameinput_options = options.merge(no_label: true,name: custom_field_field_name,diff --git a/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb b/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rbindex 0e207a70407..a946d02cb7d 100644--- a/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb+++ b/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb@@ -269,7 +269,7 @@ module Redminedef add_custom_value_errors!(custom_value)custom_value.errors.each do |error|- name = custom_value.custom_field.accessor_name.to_sym+ name = custom_value.custom_field.attribute_name.to_symdetails = error.details@@ -319,15 +319,12 @@ module Redmineenddef add_custom_field_accessors(custom_field)- getter_name = custom_field.accessor_name- setter_name = "#{getter_name}="-- define_custom_field_getter(getter_name, custom_field)- define_custom_field_setter(setter_name, custom_field)+ define_custom_field_getter(custom_field)+ define_custom_field_setter(custom_field)end- def define_custom_field_getter(getter_name, custom_field)- define_singleton_method getter_name do+ def define_custom_field_getter(custom_field)+ define_singleton_method custom_field.attribute_getter docustom_values = Array(custom_value_for(custom_field)).map do |custom_value|custom_value ? custom_value.typed_value : nilend@@ -340,8 +337,8 @@ module Redmineendend- def define_custom_field_setter(setter_name, custom_field)- define_singleton_method setter_name do |value|+ def define_custom_field_setter(custom_field)+ define_singleton_method custom_field.attribute_setter do |value|# N.B. we do no strict type checking here, it would be possible to assign a user# to an integer custom field...value = value.id if value.respond_to?(:id)diff --git a/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb b/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rbindex 027f0e62bb3..811dcea0d59 100644--- a/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb+++ b/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb@@ -273,7 +273,7 @@ describe API::V3::TimeEntries::Schemas::TimeEntrySchemaRepresenter docontext 'for a custom value' dolet(:custom_field) { build_stubbed(:text_time_entry_custom_field) }let(:path) { "customField#{custom_field.id}" }- let(:writable_attributes) { ["custom_field_#{custom_field.id}"] }+ let(:writable_attributes) { [custom_field.attribute_name] }before doallow(contract)diff --git a/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb b/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rbindex c0451e38c44..f7d4e5b16a9 100644--- a/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb+++ b/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb@@ -125,7 +125,7 @@ describe API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do.and_return([custom_field])allow(time_entry)- .to receive(:"custom_field_#{custom_field.id}")+ .to receive(custom_field.attribute_getter).and_return(user)allow(time_entry)@@ -268,7 +268,7 @@ describe API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do.and_return([custom_field])allow(time_entry)- .to receive(:"custom_field_#{custom_field.id}")+ .to receive(custom_field.attribute_getter).and_return(custom_value.value)enddiff --git a/modules/costs/spec/requests/api/time_entry_resource_spec.rb b/modules/costs/spec/requests/api/time_entry_resource_spec.rbindex 083ea150419..55836543f8d 100644--- a/modules/costs/spec/requests/api/time_entry_resource_spec.rb+++ b/modules/costs/spec/requests/api/time_entry_resource_spec.rb@@ -438,7 +438,7 @@ describe 'API v3 time_entry resource' doexpect(new_entry.spent_on).to eql Date.parse("2017-07-28")- expect(new_entry.send(:"custom_field_#{custom_field.id}"))+ expect(new_entry.send(custom_field.attribute_getter)).to eql 'some cf text'enddiff --git a/modules/dashboards/spec/features/project_details_spec.rb b/modules/dashboards/spec/features/project_details_spec.rbindex d373a855c5b..3d52b1ddcc2 100644--- a/modules/dashboards/spec/features/project_details_spec.rb+++ b/modules/dashboards/spec/features/project_details_spec.rb@@ -44,14 +44,14 @@ describe 'Project details widget on dashboard', js: true dolet!(:project) docreate(:project, members: { other_user => role }).tap do |p|- p.send(:"custom_field_#{int_cf.id}=", 5)- p.send(:"custom_field_#{bool_cf.id}=", true)- p.send(:"custom_field_#{version_cf.id}=", system_version)- p.send(:"custom_field_#{float_cf.id}=", 4.5)- p.send(:"custom_field_#{text_cf.id}=", 'Some **long** text')- p.send(:"custom_field_#{string_cf.id}=", 'Some small text')- p.send(:"custom_field_#{date_cf.id}=", Date.today)- p.send(:"custom_field_#{user_cf.id}=", other_user)+ p.send(int_cf.attribute_setter, 5)+ p.send(bool_cf.attribute_setter, true)+ p.send(version_cf.attribute_setter, system_version)+ p.send(float_cf.attribute_setter, 4.5)+ p.send(text_cf.attribute_setter, 'Some **long** text')+ p.send(string_cf.attribute_setter, 'Some small text')+ p.send(date_cf.attribute_setter, Date.today)+ p.send(user_cf.attribute_setter, other_user)p.save!(validate: false)enddiff --git a/modules/reporting/spec/features/custom_fields_spec.rb b/modules/reporting/spec/features/custom_fields_spec.rbindex d54c883c115..7f579bcc8db 100644--- a/modules/reporting/spec/features/custom_fields_spec.rb+++ b/modules/reporting/spec/features/custom_fields_spec.rb@@ -180,7 +180,7 @@ describe 'Custom fields reporting', js: true doendit 'groups by the raw values when an invalid value exists' do- expect(work_package2.send("custom_field_#{custom_field_2.id}")).to eq(['invalid not found'])+ expect(work_package2.send(custom_field_2.attribute_getter)).to eq(['invalid not found'])expect(page).to have_selector('#group-by--add-columns')expect(page).to have_selector('#group-by--add-rows')diff --git a/modules/reporting/spec/models/cost_query/filter_spec.rb b/modules/reporting/spec/models/cost_query/filter_spec.rbindex 199ee8fbcc8..6abbea4f2a1 100644--- a/modules/reporting/spec/models/cost_query/filter_spec.rb+++ b/modules/reporting/spec/models/cost_query/filter_spec.rb@@ -457,15 +457,15 @@ describe CostQuery, reporting_query_helper: true doit "is usable as filter" docreate_searchable_fields_and_values- id = WorkPackageCustomField.find_by(name: "Searchable Field").id- query.filter "custom_field_#{id}".to_sym, operator: '=', value: "125"+ cf = WorkPackageCustomField.find_by(name: "Searchable Field")+ query.filter cf.attribute_name, operator: '=', value: "125"expect(query.result.count).to eq(2)endit "is usable as filter #2" docreate_searchable_fields_and_values- id = WorkPackageCustomField.find_by(name: "Searchable Field").id- query.filter "custom_field_#{id}".to_sym, operator: '=', value: "finnlabs"+ cf = WorkPackageCustomField.find_by(name: "Searchable Field")+ query.filter cf.attribute_name, operator: '=', value: "finnlabs"expect(query.result.count).to eq(0)endenddiff --git a/modules/reporting/spec/models/cost_query/group_by_spec.rb b/modules/reporting/spec/models/cost_query/group_by_spec.rbindex 8dd0dd193da..1dc998efe71 100644--- a/modules/reporting/spec/models/cost_query/group_by_spec.rb+++ b/modules/reporting/spec/models/cost_query/group_by_spec.rb@@ -306,7 +306,7 @@ describe CostQuery, reporting_query_helper: true docheck_cache- query.group_by "custom_field_#{custom_field2.id}".to_sym+ query.group_by custom_field2.attribute_namefootprint = query.result.each_direct_result.map { |c| [c.count, c.units.to_i] }.sortexpect(footprint).to eq([[8, 8]])enddiff --git a/modules/xls_export/spec/models/xls_export/work_package/exporter/xls_integration_spec.rb b/modules/xls_export/spec/models/xls_export/work_package/exporter/xls_integration_spec.rbindex ac891016563..eb09e8820c7 100644--- a/modules/xls_export/spec/models/xls_export/work_package/exporter/xls_integration_spec.rb+++ b/modules/xls_export/spec/models/xls_export/work_package/exporter/xls_integration_spec.rb@@ -187,11 +187,11 @@ describe XlsExport::WorkPackage::Exporter::XLS dotype:)wps[0].estimated_hours = 27.5wps[0].save!- wps[1].send(:"custom_field_#{custom_field.id}=", 1)+ wps[1].send(custom_field.attribute_setter, 1)wps[1].save!- wps[2].send(:"custom_field_#{custom_field.id}=", 99.99)+ wps[2].send(custom_field.attribute_setter, 99.99)wps[2].save!- wps[3].send(:"custom_field_#{custom_field.id}=", 1000)+ wps[3].send(custom_field.attribute_setter, 1000)wps[3].save!wpsenddiff --git a/spec/contracts/work_packages/update_contract_spec.rb b/spec/contracts/work_packages/update_contract_spec.rbindex 5fd15147838..59605d155ce 100644--- a/spec/contracts/work_packages/update_contract_spec.rb+++ b/spec/contracts/work_packages/update_contract_spec.rb@@ -419,7 +419,7 @@ describe WorkPackages::UpdateContract doshared_examples_for 'custom_field readonly errors' doit 'adds an error to the written custom field attribute' do- expect(contract.errors.symbols_for(:"custom_field_#{cf1.id}"))+ expect(contract.errors.symbols_for(cf1.attribute_name.to_sym)).to include(:error_readonly)enddiff --git a/spec/features/statuses/read_only_statuses_spec.rb b/spec/features/statuses/read_only_statuses_spec.rbindex fb1304a50d9..5e48ec0a926 100644--- a/spec/features/statuses/read_only_statuses_spec.rb+++ b/spec/features/statuses/read_only_statuses_spec.rb@@ -102,7 +102,7 @@ describe 'Read-only statuses affect work package editing',assignee_field.label_element.clickassignee_field.expect_inactive!- custom_field = wp_page.edit_field cf_all.accessor_name.camelcase(:lower)+ custom_field = wp_page.edit_field cf_all.attribute_name.camelcase(:lower)custom_field.label_element.clickcustom_field.expect_inactive!enddiff --git a/spec/features/types/form_configuration_spec.rb b/spec/features/types/form_configuration_spec.rbindex 9a963b324eb..7a6350023df 100644--- a/spec/features/types/form_configuration_spec.rb+++ b/spec/features/types/form_configuration_spec.rb@@ -249,8 +249,8 @@ describe 'form configuration', js: true dodescribe 'required custom field' dolet(:custom_fields) { [custom_field] }let(:custom_field) { create(:integer_issue_custom_field, is_required: true, name: 'MyNumber') }- let(:cf_identifier) { "custom_field_#{custom_field.id}" }- let(:cf_identifier_api) { "customField#{custom_field.id}" }+ let(:cf_identifier) { custom_field.attribute_name }+ let(:cf_identifier_api) { cf_identifier.camelcase(:lower) }before doproject@@ -279,8 +279,8 @@ describe 'form configuration', js: true dolet(:custom_fields) { [custom_field] }let(:custom_field) { create(:integer_issue_custom_field, name: 'MyNumber') }- let(:cf_identifier) { "custom_field_#{custom_field.id}" }- let(:cf_identifier_api) { "customField#{custom_field.id}" }+ let(:cf_identifier) { custom_field.attribute_name }+ let(:cf_identifier_api) { cf_identifier.camelcase(:lower) }before doprojectdiff --git a/spec/features/types/reset_form_configuration_spec.rb b/spec/features/types/reset_form_configuration_spec.rbindex 3497bf6b823..a86f33c050b 100644--- a/spec/features/types/reset_form_configuration_spec.rb+++ b/spec/features/types/reset_form_configuration_spec.rb@@ -39,8 +39,8 @@ describe 'Reset form configuration', js: true dodescribe "with EE token and CFs" dolet(:custom_fields) { [custom_field] }let(:custom_field) { create(:integer_issue_custom_field, is_required: true, name: 'MyNumber') }- let(:cf_identifier) { "custom_field_#{custom_field.id}" }- let(:cf_identifier_api) { "customField#{custom_field.id}" }+ let(:cf_identifier) { custom_field.attribute_name }+ let(:cf_identifier_api) { cf_identifier.camelcase(:lower) }before dowith_enterprise_token(:edit_attribute_groups)diff --git a/spec/features/work_packages/bulk/update_work_package_spec.rb b/spec/features/work_packages/bulk/update_work_package_spec.rbindex 7e1c058d363..03ae1ed0be7 100644--- a/spec/features/work_packages/bulk/update_work_package_spec.rb+++ b/spec/features/work_packages/bulk/update_work_package_spec.rb@@ -144,8 +144,8 @@ describe 'Bulk update work packages through Rails view', js: true docontext 'with enterprise', with_ee: [:readonly_work_packages] doit 'does not update the work packages' do- expect(work_package.send(custom_field.accessor_name)).to be_nil- expect(work_package2.send(custom_field.accessor_name)).to be_nil+ expect(work_package.send(custom_field.attribute_getter)).to be_nil+ expect(work_package2.send(custom_field.attribute_getter)).to be_nilfill_in custom_field.name, with: 'Custom field text'click_on 'Submit'@@ -170,18 +170,18 @@ describe 'Bulk update work packages through Rails view', js: true dowork_package.reloadwork_package2.reload- expect(work_package.send(custom_field.accessor_name))+ expect(work_package.send(custom_field.attribute_getter)).to eq('Custom field text')- expect(work_package2.send(custom_field.accessor_name))+ expect(work_package2.send(custom_field.attribute_getter)).to be_nilendendcontext 'without enterprise', with_ee: false doit 'ignores the readonly status and updates the work packages' do- expect(work_package.send(custom_field.accessor_name)).to be_nil- expect(work_package2.send(custom_field.accessor_name)).to be_nil+ expect(work_package.send(custom_field.attribute_getter)).to be_nil+ expect(work_package2.send(custom_field.attribute_getter)).to be_nilfill_in custom_field.name, with: 'Custom field text'click_on 'Submit'@@ -192,10 +192,10 @@ describe 'Bulk update work packages through Rails view', js: true dowork_package.reloadwork_package2.reload- expect(work_package.send(custom_field.accessor_name))+ expect(work_package.send(custom_field.attribute_getter)).to eq('Custom field text')- expect(work_package2.send(custom_field.accessor_name))+ expect(work_package2.send(custom_field.attribute_getter)).to eq('Custom field text')endenddiff --git a/spec/features/work_packages/custom_actions/custom_actions_spec.rb b/spec/features/work_packages/custom_actions/custom_actions_spec.rbindex 84abaea830e..2b72a64dbd7 100644--- a/spec/features/work_packages/custom_actions/custom_actions_spec.rb+++ b/spec/features/work_packages/custom_actions/custom_actions_spec.rb@@ -241,7 +241,7 @@ describe 'Custom actions', js: true do# This custom field is not applicablenew_ca_page.add_action(int_custom_field.name, '1')- new_ca_page.expect_action("custom_field_#{int_custom_field.id}", '1')+ new_ca_page.expect_action(int_custom_field.attribute_name, '1')new_ca_page.set_condition('Status', closed_status.name)new_ca_page.expect_selected_option closed_status.namediff --git a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb b/spec/features/work_packages/details/custom_fields/custom_field_spec.rbindex 312d68414fe..3a1da5a7dee 100644--- a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb+++ b/spec/features/work_packages/details/custom_fields/custom_field_spec.rb@@ -188,7 +188,7 @@ describe 'custom field inplace editor', js: true dofield.save!work_package.reload- expect(work_package.send("custom_field_#{custom_field.id}")).to eq 123+ expect(work_package.send(custom_field.attribute_getter)).to eq 123endendenddiff --git a/spec/features/work_packages/new/attributes_from_filter_spec.rb b/spec/features/work_packages/new/attributes_from_filter_spec.rbindex 32ce24c08fa..6622a56c920 100644--- a/spec/features/work_packages/new/attributes_from_filter_spec.rb+++ b/spec/features/work_packages/new/attributes_from_filter_spec.rb@@ -104,7 +104,7 @@ RSpec.describe 'Work package create uses attributes from filters', js: true, sel)wp = WorkPackage.lastexpect(wp.subject).to eq 'Foobar!'- expect(wp.send("custom_field_#{custom_field.id}")).to eq %w(A)+ expect(wp.send(custom_field.attribute_getter)).to eq %w(A)expect(wp.type_id).to eq type_task.idendenddiff --git a/spec/features/work_packages/table/edit_work_packages_spec.rb b/spec/features/work_packages/table/edit_work_packages_spec.rbindex 81f0ce459f1..c070ad9cbb2 100644--- a/spec/features/work_packages/table/edit_work_packages_spec.rb+++ b/spec/features/work_packages/table/edit_work_packages_spec.rb@@ -193,8 +193,8 @@ describe 'Inline editing work packages', js: true do)work_package.reload- expect(work_package.send(custom_fields.first.accessor_name)).to eq('bar')- expect(work_package.send(custom_fields.last.accessor_name)).to eq('my custom text')+ expect(work_package.send(custom_fields.first.attribute_getter)).to eq('bar')+ expect(work_package.send(custom_fields.last.attribute_getter)).to eq('my custom text')# Saveguard to let the background update completewp_table.visit!diff --git a/spec/features/work_packages/table/queries/filter_spec.rb b/spec/features/work_packages/table/queries/filter_spec.rbindex 658fab707fb..9e8bdee433f 100644--- a/spec/features/work_packages/table/queries/filter_spec.rb+++ b/spec/features/work_packages/table/queries/filter_spec.rb@@ -216,14 +216,14 @@ describe 'filter work packages', js: true dolet(:work_package_with_list_value) dowp = create :work_package, project: project, type: type- wp.send("#{list_cf.accessor_name}=", list_cf.custom_options.first.id)+ wp.send(list_cf.attribute_setter, list_cf.custom_options.first.id)wp.save!wpendlet(:work_package_with_anti_list_value) dowp = create :work_package, project: project, type: type- wp.send("#{list_cf.accessor_name}=", list_cf.custom_options.last.id)+ wp.send(list_cf.attribute_setter, list_cf.custom_options.last.id)wp.save!wpend@@ -294,14 +294,14 @@ describe 'filter work packages', js: true dolet(:work_package_plus) dowp = create :work_package, project: project, type: type- wp.send("#{string_cf.accessor_name}=", 'G+H')+ wp.send(string_cf.attribute_setter, 'G+H')wp.save!wpendlet(:work_package_and) dowp = create :work_package, project: project, type: type- wp.send("#{string_cf.accessor_name}=", 'A&B')+ wp.send(string_cf.attribute_setter, 'A&B')wp.save!wpenddiff --git a/spec/features/work_packages/table/queries/me_filter_spec.rb b/spec/features/work_packages/table/queries/me_filter_spec.rbindex 8d80ef3aa59..b3a84b3336a 100644--- a/spec/features/work_packages/table/queries/me_filter_spec.rb+++ b/spec/features/work_packages/table/queries/me_filter_spec.rb@@ -147,8 +147,8 @@ describe 'filter me value', js: true domembers: project_members)end- let(:cf_accessor) { "cf_#{custom_field.id}" }- let(:cf_accessor_frontend) { "customField#{custom_field.id}" }+ let(:cf_accessor) { custom_field.attribute_name }+ let(:cf_accessor_frontend) { cf_accessor.camelcase(:lower) }let(:wp_admin) docreate :work_package,type: type_task,diff --git a/spec/features/work_packages/table/switch_types_spec.rb b/spec/features/work_packages/table/switch_types_spec.rbindex 81637987ae3..bf50fc0f8ef 100644--- a/spec/features/work_packages/table/switch_types_spec.rb+++ b/spec/features/work_packages/table/switch_types_spec.rb@@ -257,7 +257,7 @@ describe 'Switching types in work package table', js: true dowork_package.reloadexpect(work_package.type_id).to eq(type_bug.id)- expect(work_package.send("custom_field_#{cf_req_bool.id}")).to be(false)+ expect(work_package.send(cf_req_bool.attribute_getter)).to be(false)endenddiff --git a/spec/lib/api/v3/projects/project_representer_rendering_spec.rb b/spec/lib/api/v3/projects/project_representer_rendering_spec.rbindex 83f3d42265f..4fbf633d3c1 100644--- a/spec/lib/api/v3/projects/project_representer_rendering_spec.rb+++ b/spec/lib/api/v3/projects/project_representer_rendering_spec.rb@@ -43,7 +43,7 @@ describe API::V3::Projects::ProjectRepresenter, 'rendering' do.and_return([int_custom_field, version_custom_field])allow(p)- .to receive(:"custom_field_#{int_custom_field.id}")+ .to receive(int_custom_field.attribute_getter).and_return(int_custom_value.value)allow(p)diff --git a/spec/lib/api/v3/utilities/custom_field_injector_spec.rb b/spec/lib/api/v3/utilities/custom_field_injector_spec.rbindex 7814712b2db..f7cb0125db1 100644--- a/spec/lib/api/v3/utilities/custom_field_injector_spec.rb+++ b/spec/lib/api/v3/utilities/custom_field_injector_spec.rb@@ -333,7 +333,7 @@ describe API::V3::Utilities::CustomFieldInjector doit 'on writing it sets on the represented' doexpected = { custom_field.id => expected_setter }expect(represented)- .to receive(:"custom_field_#{custom_field.id}=")+ .to receive(custom_field.attribute_setter).with(expected_setter)modified_class.new(represented, current_user: nil)@@ -346,7 +346,7 @@ describe API::V3::Utilities::CustomFieldInjector dolet(:represented) dodouble('represented',available_custom_fields: [custom_field],- custom_field.accessor_name => value)+ custom_field.attribute_name => value)endlet(:custom_value) { double('CustomValue', value: raw_value, typed_value:) }let(:raw_value) { nil }@@ -539,7 +539,7 @@ describe API::V3::Utilities::CustomFieldInjector dobefore doallow(represented).to receive(:custom_value_for).with(custom_field).and_return(custom_value)- allow(represented).to receive(:"custom_field_#{custom_field.id}").and_return(typed_value)+ allow(represented).to receive(custom_field.attribute_getter).and_return(typed_value)endcontext 'reading' do@@ -578,7 +578,7 @@ describe API::V3::Utilities::CustomFieldInjector dojson = { cf_path => { href: path } }.to_jsonexpected = ['2']- expect(represented).to receive(:"custom_field_#{custom_field.id}=").with(expected)+ expect(represented).to receive(custom_field.attribute_setter).with(expected)modified_class.new(represented, current_user: nil).from_json(json)endend@@ -587,7 +587,7 @@ describe API::V3::Utilities::CustomFieldInjector dojson = { cf_path => { href: nil } }.to_jsonexpected = []- expect(represented).to receive(:"custom_field_#{custom_field.id}=").with(expected)+ expect(represented).to receive(custom_field.attribute_setter).with(expected)modified_class.new(represented, current_user: nil).from_json(json)endenddiff --git a/spec/lib/api/v3/versions/version_representer_rendering_spec.rb b/spec/lib/api/v3/versions/version_representer_rendering_spec.rbindex 0de939dfa85..a676b9dc524 100644--- a/spec/lib/api/v3/versions/version_representer_rendering_spec.rb+++ b/spec/lib/api/v3/versions/version_representer_rendering_spec.rb@@ -211,7 +211,7 @@ describe API::V3::Versions::VersionRepresenter, 'rendering' do.and_return([custom_field])allow(version)- .to receive(:"custom_field_#{custom_field.id}")+ .to receive(custom_field.attribute_getter).and_return(custom_value.value)end@@ -283,7 +283,7 @@ describe API::V3::Versions::VersionRepresenter, 'rendering' do.and_return([custom_field])allow(version)- .to receive(:"custom_field_#{custom_field.id}")+ .to receive(custom_field.attribute_getter).and_return('123')enddiff --git a/spec/lib/api/v3/work_packages/eager_loading/custom_value_integration_spec.rb b/spec/lib/api/v3/work_packages/eager_loading/custom_value_integration_spec.rbindex d698684afea..7f7e5d4ceeb 100644--- a/spec/lib/api/v3/work_packages/eager_loading/custom_value_integration_spec.rb+++ b/spec/lib/api/v3/work_packages/eager_loading/custom_value_integration_spec.rb@@ -118,11 +118,11 @@ describe API::V3::WorkPackages::EagerLoading::CustomValue dotype_project_user_cf,for_all_type_cf]- expect(work_package.send(:"custom_field_#{type_project_version_cf.id}"))+ expect(work_package.send(type_project_version_cf.attribute_getter)).to eql version- expect(work_package.send(:"custom_field_#{type_project_list_cf.id}"))+ expect(work_package.send(type_project_list_cf.attribute_getter)).to eql type_project_list_cf.custom_options.last.name- expect(work_package.send(:"custom_field_#{type_project_user_cf.id}"))+ expect(work_package.send(type_project_user_cf.attribute_getter)).to eql userendenddiff --git a/spec/lib/custom_field_form_builder_spec.rb b/spec/lib/custom_field_form_builder_spec.rbindex d85082ffeac..6f27f44eada 100644--- a/spec/lib/custom_field_form_builder_spec.rb+++ b/spec/lib/custom_field_form_builder_spec.rb@@ -59,7 +59,7 @@ describe CustomFieldFormBuilder dobefore doallow(resource)- .to receive(custom_field.accessor_name)+ .to receive(custom_field.attribute_getter).and_return(typed_value)end@@ -256,7 +256,7 @@ describe CustomFieldFormBuilder docustom_field.field_format = 'user'allow(project)- .to receive(custom_field.accessor_name)+ .to receive(custom_field.attribute_getter).and_return typed_valueallow(project)@@ -311,7 +311,7 @@ describe CustomFieldFormBuilder dobefore docustom_field.field_format = 'version'allow(project)- .to receive(custom_field.accessor_name)+ .to receive(custom_field.attribute_getter).and_return typed_valueallow(project)diff --git a/spec/lib/open_project/changed_by_system_spec.rb b/spec/lib/open_project/changed_by_system_spec.rbindex d7ef5a92022..431750acc2b 100644--- a/spec/lib/open_project/changed_by_system_spec.rb+++ b/spec/lib/open_project/changed_by_system_spec.rb@@ -109,7 +109,7 @@ describe OpenProject::ChangedBySystem doit 'returns the custom fields too' domodel.custom_field_values = { cf1.id => 'test' }expect(model.changed_by_user)- .to include("custom_field_#{cf1.id}")+ .to include(cf1.attribute_name)endendenddiff --git a/spec/models/attribute_help_text/work_package_spec.rb b/spec/models/attribute_help_text/work_package_spec.rbindex 541d0e3856e..367c129668a 100644--- a/spec/models/attribute_help_text/work_package_spec.rb+++ b/spec/models/attribute_help_text/work_package_spec.rb@@ -35,7 +35,7 @@ describe AttributeHelpText::WorkPackage do# need to clear the cache to free the memoized# Type.translated_work_package_form_attributesRails.cache.clear- create(:work_package_help_text, attribute_name: "custom_field_#{custom_field.id}")+ create(:work_package_help_text, attribute_name: custom_field.attribute_name)endlet(:wp_custom_field) { create :text_wp_custom_field }diff --git a/spec/models/custom_actions/actions/custom_field_spec.rb b/spec/models/custom_actions/actions/custom_field_spec.rbindex 4f79749eb84..30f075d095b 100644--- a/spec/models/custom_actions/actions/custom_field_spec.rb+++ b/spec/models/custom_actions/actions/custom_field_spec.rb@@ -85,7 +85,7 @@ describe CustomActions::Actions::CustomField do.with(id: custom_field.id.to_s).and_return(custom_field)- described_class.for(:"custom_field_#{custom_field.id}")+ described_class.for(custom_field.attribute_name)endlet(:instance) doklass.new@@ -113,14 +113,14 @@ describe CustomActions::Actions::CustomField dodescribe '.key' doit 'is the custom field accessor' doexpect(klass.key)- .to eql(:"custom_field_#{custom_field.id}")+ .to eql(custom_field.attribute_getter)endenddescribe '#key' doit 'is the custom field accessor' doexpect(instance.key)- .to eql(:"custom_field_#{custom_field.id}")+ .to eql(custom_field.attribute_getter)endend@@ -587,7 +587,7 @@ describe CustomActions::Actions::CustomField doit "sets the value for #{type} custom fields" doexpect(work_package)- .to receive(:"custom_field_#{custom_field.id}=")+ .to receive(custom_field.attribute_setter).with([42])instance.values = 42@@ -601,7 +601,7 @@ describe CustomActions::Actions::CustomField doit "sets the value to today for a dynamic value" doexpect(work_package)- .to receive(:"custom_field_#{custom_field.id}=")+ .to receive(custom_field.attribute_setter).with(Date.today)instance.values = '%CURRENT_DATE%'diff --git a/spec/models/custom_field_spec.rb b/spec/models/custom_field_spec.rbindex 62f2e1cf472..e980fbb7f1c 100644--- a/spec/models/custom_field_spec.rb+++ b/spec/models/custom_field_spec.rb@@ -183,12 +183,28 @@ describe CustomField doendend- describe '#accessor_name' do- let(:field) { build_stubbed :custom_field }+ describe '#attribute_name' do+ let(:field) { build_stubbed(:custom_field) }- it 'is formatted as expected' do- expect(field.accessor_name).to eql("custom_field_#{field.id}")- end+ subject { field.attribute_name }++ it { is_expected.to eq("custom_field_#{field.id}") }+ end++ describe '#attribute_getter' do+ let(:field) { build_stubbed(:custom_field) }++ subject { field.attribute_getter }++ it { is_expected.to eq(:"custom_field_#{field.id}") }+ end++ describe '#attribute_setter' do+ let(:field) { build_stubbed(:custom_field) }++ subject { field.attribute_setter }++ it { is_expected.to eq(:"custom_field_#{field.id}=") }enddescribe '#possible_values_options' dodiff --git a/spec/models/custom_value/list_strategy_integration_spec.rb b/spec/models/custom_value/list_strategy_integration_spec.rbindex ad7eb1eae9a..2d38ea466c3 100644--- a/spec/models/custom_value/list_strategy_integration_spec.rb+++ b/spec/models/custom_value/list_strategy_integration_spec.rb@@ -50,13 +50,13 @@ describe CustomValue::ListStrategy, 'integration tests' doendit 'can handle invalid CustomOptions (Regression test)' do- expect(work_package.public_send(:"custom_field_#{custom_field.id}")).to eq(%w(A))+ expect(work_package.public_send(custom_field.attribute_getter)).to eq(%w(A))# Remove the custom value without replacementCustomValue.find_by(customized_id: work_package.id).update_columns(value: 'invalid')work_package.reloadwork_package.reset_custom_values!- expect(work_package.public_send(:"custom_field_#{custom_field.id}")).to eq(['invalid not found'])+ expect(work_package.public_send(custom_field.attribute_getter)).to eq(['invalid not found'])endenddiff --git a/spec/models/projects/exporter/exportable_project_context.rb b/spec/models/projects/exporter/exportable_project_context.rbindex a5cc343e120..19dce8c87cd 100644--- a/spec/models/projects/exporter/exportable_project_context.rb+++ b/spec/models/projects/exporter/exportable_project_context.rb@@ -51,14 +51,14 @@ shared_context 'with a project with an arrangement of custom fields' doshared_let(:project) docreate(:project, members: { other_user => role }).tap do |p|p.description = "The description of the project"- p.send(:"custom_field_#{int_cf.id}=", 5)- p.send(:"custom_field_#{bool_cf.id}=", true)- p.send(:"custom_field_#{version_cf.id}=", system_version)- p.send(:"custom_field_#{float_cf.id}=", 4.5)- p.send(:"custom_field_#{text_cf.id}=", 'Some **long** text')- p.send(:"custom_field_#{string_cf.id}=", 'Some small text')- p.send(:"custom_field_#{date_cf.id}=", Time.zone.today)- p.send(:"custom_field_#{user_cf.id}=", other_user)+ p.send(int_cf.attribute_setter, 5)+ p.send(bool_cf.attribute_setter, true)+ p.send(version_cf.attribute_setter, system_version)+ p.send(float_cf.attribute_setter, 4.5)+ p.send(text_cf.attribute_setter, 'Some **long** text')+ p.send(string_cf.attribute_setter, 'Some small text')+ p.send(date_cf.attribute_setter, Time.zone.today)+ p.send(user_cf.attribute_setter, other_user)p.build_status(code: :off_track)diff --git a/spec/models/query/results_spec.rb b/spec/models/query/results_spec.rbindex af4aace1ab3..1a0b49ec663 100644--- a/spec/models/query/results_spec.rb+++ b/spec/models/query/results_spec.rb@@ -196,10 +196,10 @@ describe Query::Results, with_mail: false dobefore dologin_as(user1)- work_package1.send(:"custom_field_#{custom_field.id}=", first_value)+ work_package1.send(custom_field.attribute_setter, first_value)work_package1.save!- work_package2.send(:"custom_field_#{custom_field.id}=", [first_value,- last_value])+ work_package2.send(custom_field.attribute_setter, [first_value,+ last_value])work_package2.save!end@@ -229,9 +229,9 @@ describe Query::Results, with_mail: false dowp_p1[0].type.custom_fields << custom_fieldproject1.work_package_custom_fields << custom_field- wp_p1[0].update_attribute(:"custom_field_#{custom_field.id}", 42)+ wp_p1[0].update_attribute(custom_field.attribute_name, 42)wp_p1[0].save- wp_p1[1].update_attribute(:"custom_field_#{custom_field.id}", 42)+ wp_p1[1].update_attribute(custom_field.attribute_name, 42)wp_p1[1].saveend@@ -272,9 +272,9 @@ describe Query::Results, with_mail: false dowp_p1[0].type.custom_fields << custom_fieldproject1.work_package_custom_fields << custom_field- wp_p1[0].update_attribute(:"custom_field_#{custom_field.id}", true)+ wp_p1[0].update_attribute(custom_field.attribute_name, true)wp_p1[0].save- wp_p1[1].update_attribute(:"custom_field_#{custom_field.id}", true)+ wp_p1[1].update_attribute(custom_field.attribute_name, true)wp_p1[1].saveend@@ -296,9 +296,9 @@ describe Query::Results, with_mail: false dowp_p1[0].type.custom_fields << custom_fieldproject1.work_package_custom_fields << custom_field- wp_p1[0].update_attribute(:"custom_field_#{custom_field.id}", Time.zone.today)+ wp_p1[0].update_attribute(custom_field.attribute_name, Time.zone.today)wp_p1[0].save- wp_p1[1].update_attribute(:"custom_field_#{custom_field.id}", Time.zone.today)+ wp_p1[1].update_attribute(custom_field.attribute_name, Time.zone.today)wp_p1[1].saveenddiff --git a/spec/models/query/results_sums_integration_spec.rb b/spec/models/query/results_sums_integration_spec.rbindex 2aaed23b2c8..d28ecbbde15 100644--- a/spec/models/query/results_sums_integration_spec.rb+++ b/spec/models/query/results_sums_integration_spec.rb@@ -55,8 +55,8 @@ describe Query::Results, 'sums' doproject:,estimated_hours: 5,done_ratio: 10,- "custom_field_#{int_cf.id}" => 10,- "custom_field_#{float_cf.id}" => 3.414,+ int_cf.attribute_name => 10,+ float_cf.attribute_name => 3.414,remaining_hours: 3,story_points: 7)end@@ -67,8 +67,8 @@ describe Query::Results, 'sums' doassigned_to: current_user,done_ratio: 50,estimated_hours: 5,- "custom_field_#{int_cf.id}" => 10,- "custom_field_#{float_cf.id}" => 3.414,+ int_cf.attribute_name => 10,+ float_cf.attribute_name => 3.414,remaining_hours: 3,story_points: 7)end@@ -80,8 +80,8 @@ describe Query::Results, 'sums' doresponsible: current_user,done_ratio: 50,estimated_hours: 5,- "custom_field_#{int_cf.id}" => 10,- "custom_field_#{float_cf.id}" => 3.414,+ int_cf.attribute_name => 10,+ float_cf.attribute_name => 3.414,remaining_hours: 3,story_points: 7)end@@ -90,8 +90,8 @@ describe Query::Results, 'sums' dotype:,project: other_project,estimated_hours: 5,- "custom_field_#{int_cf.id}" => 10,- "custom_field_#{float_cf.id}" => 3.414,+ int_cf.attribute_name => 10,+ float_cf.attribute_name => 3.414,remaining_hours: 3,story_points: 7)enddiff --git a/spec/models/type/attribute_groups_spec.rb b/spec/models/type/attribute_groups_spec.rbindex c56b1e13909..1da838e439e 100644--- a/spec/models/type/attribute_groups_spec.rb+++ b/spec/models/type/attribute_groups_spec.rb@@ -163,7 +163,7 @@ describe Type do)endlet(:cf_identifier) do- :"custom_field_#{custom_field.id}"+ custom_field.attribute_nameendit 'can be put into attribute groups' do@@ -171,7 +171,7 @@ describe Type doOpenProject::Cache.clear# Can be enabled- type.attribute_groups = [['foo', [cf_identifier.to_s]]]+ type.attribute_groups = [['foo', [cf_identifier]]]expect(type.save).to be_truthyexpect(type.read_attribute(:attribute_groups)).not_to be_emptyend@@ -184,7 +184,7 @@ describe Type do)endlet(:cf_identifier2) do- :"custom_field_#{custom_field2.id}"+ custom_field2.attribute_nameendit 'they are kept in their respective positions in the group (Regression test #27940)' do@@ -192,12 +192,12 @@ describe Type doOpenProject::Cache.clear# Can be enabled- type.attribute_groups = [['foo', [cf_identifier2.to_s, cf_identifier.to_s]]]+ type.attribute_groups = [['foo', [cf_identifier2, cf_identifier]]]expect(type.save).to be_truthyexpect(type.read_attribute(:attribute_groups)).not_to be_emptycf_group = type.attribute_groups[0]- expect(cf_group.members).to eq([cf_identifier2.to_s, cf_identifier.to_s])+ expect(cf_group.members).to eq([cf_identifier2, cf_identifier])endendend@@ -220,7 +220,7 @@ describe Type doother_group = type.attribute_groups.detect { |g| g.key == :other }expect(other_group).to be_present- expect(other_group.attributes).to eq([custom_field.accessor_name])+ expect(other_group.attributes).to eq([custom_field.attribute_name])# It is removed again when resetting ittype.reset_attribute_groupsdiff --git a/spec/models/work_package/work_package_acts_as_customizable_spec.rb b/spec/models/work_package/work_package_acts_as_customizable_spec.rbindex 7040082ae4b..a3f0b9a89b3 100644--- a/spec/models/work_package/work_package_acts_as_customizable_spec.rb+++ b/spec/models/work_package/work_package_acts_as_customizable_spec.rb@@ -67,7 +67,7 @@ describe WorkPackage, 'acts_as_customizable' doendit 'sets the value' do- expect(wp_with_assignee_cf.send(version_cf.accessor_name))+ expect(wp_with_assignee_cf.send(version_cf.attribute_getter)).to eql versionendend@@ -85,19 +85,19 @@ describe WorkPackage, 'acts_as_customizable' doendit 'says to respond to valid custom field accessors' do- expect(work_package).to respond_to(included_cf.accessor_name)+ expect(work_package).to respond_to(included_cf.attribute_getter)endit 'really responds to valid custom field accessors' do- expect(work_package.send(included_cf.accessor_name)).to be_nil+ expect(work_package.send(included_cf.attribute_getter)).to be_nilendit 'says to not respond to foreign custom field accessors' do- expect(work_package).not_to respond_to(other_cf.accessor_name)+ expect(work_package).not_to respond_to(other_cf.attribute_getter)endit 'does really not respond to foreign custom field accessors' do- expect { work_package.send(other_cf.accessor_name) }.to raise_error(NoMethodError)+ expect { work_package.send(other_cf.attribute_getter) }.to raise_error(NoMethodError)endend@@ -125,7 +125,7 @@ describe WorkPackage, 'acts_as_customizable' do# assert that there is only one errorexpect(work_package.errors.size).to eq 1- expect(work_package.errors["custom_field_#{cf2.id}"].size).to eq 1+ expect(work_package.errors[cf2.attribute_name].size).to eq 1endenddiff --git a/spec/models/work_package/work_package_custom_fields_spec.rb b/spec/models/work_package/work_package_custom_fields_spec.rbindex 181830cd422..4e91d26722f 100644--- a/spec/models/work_package/work_package_custom_fields_spec.rb+++ b/spec/models/work_package/work_package_custom_fields_spec.rb@@ -145,7 +145,7 @@ describe WorkPackage dodescribe 'invalid custom field values' docontext 'short error message' doshared_examples_for 'custom field with invalid value' do- let(:custom_field_key) { "custom_field_#{custom_field.id}".to_sym }+ let(:custom_field_key) { custom_field.attribute_name.to_sym }before dochange_custom_field_value(work_package, custom_field_value)diff --git a/spec/models/work_package/work_package_multi_value_custom_fields_spec.rb b/spec/models/work_package/work_package_multi_value_custom_fields_spec.rbindex c118475a950..33933d4f682 100644--- a/spec/models/work_package/work_package_multi_value_custom_fields_spec.rb+++ b/spec/models/work_package/work_package_multi_value_custom_fields_spec.rb@@ -97,7 +97,7 @@ describe WorkPackage dowork_package.custom_field_values = { custom_field.id => ids }work_package.save- expect(work_package.send("custom_field_#{custom_field.id}"))+ expect(work_package.send(custom_field.attribute_getter)).to eql valuesendenddiff --git a/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb b/spec/requests/api/v3/help_texts/help_texts_resource_spec.rbindex a91deb33e45..ae69ef5a683 100644--- a/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb+++ b/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb@@ -51,7 +51,7 @@ describe 'API v3 Help texts resource' do[create(:work_package_help_text, attribute_name: 'assignee'),create(:work_package_help_text, attribute_name: 'status'),- create(:work_package_help_text, attribute_name: "custom_field_#{custom_field.id}")+ create(:work_package_help_text, attribute_name: custom_field.attribute_name)]enddiff --git a/spec/requests/api/v3/projects/update_form_resource_spec.rb b/spec/requests/api/v3/projects/update_form_resource_spec.rbindex 9bfc6957f93..643b6224d47 100644--- a/spec/requests/api/v3/projects/update_form_resource_spec.rb+++ b/spec/requests/api/v3/projects/update_form_resource_spec.rb@@ -34,8 +34,8 @@ describe API::V3::Projects::UpdateFormAPI, content_type: :json dolet(:project) docreate(:project,- "custom_field_#{text_custom_field.id}": "CF text",- "custom_field_#{list_custom_field.id}": list_custom_field.custom_options.first)+ text_custom_field.attribute_name => "CF text",+ list_custom_field.attribute_name => list_custom_field.custom_options.first)endlet(:current_user) docreate(:user,@@ -224,10 +224,10 @@ describe API::V3::Projects::UpdateFormAPI, content_type: :json doexpect(project.identifier).to eql attributes_before['identifier']- expect(project.send("custom_field_#{text_custom_field.id}"))+ expect(project.send(text_custom_field.attribute_getter)).to eql 'CF text'- expect(project.send("custom_field_#{list_custom_field.id}"))+ expect(project.send(list_custom_field.attribute_getter)).to eql list_custom_field.custom_options.first.valueexpect(project.status)diff --git a/spec/requests/api/v3/projects/update_resource_spec.rb b/spec/requests/api/v3/projects/update_resource_spec.rbindex 133e55feabf..70239ffcd7e 100644--- a/spec/requests/api/v3/projects/update_resource_spec.rb+++ b/spec/requests/api/v3/projects/update_resource_spec.rb@@ -105,7 +105,7 @@ describe 'API v3 Project resource update', content_type: :json doendit 'sets the cf value' do- expect(project.reload.send("custom_field_#{custom_field.id}"))+ expect(project.reload.send(custom_field.attribute_getter)).to eql("CF text")endend@@ -377,7 +377,7 @@ describe 'API v3 Project resource update', content_type: :json doendit 'sets the cf value' do- expect(project.reload.send("custom_field_#{custom_field.id}"))+ expect(project.reload.send(custom_field.attribute_getter)).to eql("CF text")enddiff --git a/spec/requests/api/v3/user/update_form_resource_spec.rb b/spec/requests/api/v3/user/update_form_resource_spec.rbindex ef36bc9d588..79968f197fd 100644--- a/spec/requests/api/v3/user/update_form_resource_spec.rb+++ b/spec/requests/api/v3/user/update_form_resource_spec.rb@@ -40,8 +40,8 @@ describe API::V3::Users::UpdateFormAPI, content_type: :json doendshared_let(:user) docreate(:user,- "custom_field_#{text_custom_field.id}": "CF text",- "custom_field_#{list_custom_field.id}": list_custom_field.custom_options.first)+ text_custom_field.attribute_getter => "CF text",+ list_custom_field.attribute_getter => list_custom_field.custom_options.first)endlet(:path) { api_v3_paths.user_form(user.id) }diff --git a/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rb b/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rbindex 17897297860..42fed0bf619 100644--- a/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rb+++ b/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rb@@ -133,7 +133,7 @@ describe 'API v3 Work package form resource', with_mail: false doit 'denotes string custom_field to be writable' doexpect(subject).to be_json_eql(true)- .at_path("_embedded/schema/#{cf_all.accessor_name.camelcase(:lower)}/writable")+ .at_path("_embedded/schema/#{cf_all.attribute_name.camelcase(:lower)}/writable")endend@@ -828,7 +828,7 @@ describe 'API v3 Work package form resource', with_mail: false doit 'denotes custom_field to not be writable' doexpect(subject).to be_json_eql(false)- .at_path("_embedded/schema/#{cf_all.accessor_name.camelcase(:lower)}/writable")+ .at_path("_embedded/schema/#{cf_all.attribute_name.camelcase(:lower)}/writable")endendenddiff --git a/spec/requests/api/v3/work_packages/update_resource_spec.rb b/spec/requests/api/v3/work_packages/update_resource_spec.rbindex 52f86701818..5fe8c536999 100644--- a/spec/requests/api/v3/work_packages/update_resource_spec.rb+++ b/spec/requests/api/v3/work_packages/update_resource_spec.rb@@ -718,7 +718,7 @@ describe 'API v3 Work package resource',endlet(:value_parameter) do- { _links: { custom_field.accessor_name.camelize(:lower) => { href: value_link } } }+ { _links: { custom_field.attribute_name.camelize(:lower) => { href: value_link } } }endlet(:params) { valid_params.merge(value_parameter) }@@ -736,7 +736,7 @@ describe 'API v3 Work package resource',it 'responds with the work package assigned to the new value' doexpect(subject.body).to be_json_eql(value_link.to_json)- .at_path("_links/#{custom_field.accessor_name.camelize(:lower)}/href")+ .at_path("_links/#{custom_field.attribute_name.camelize(:lower)}/href")endit_behaves_like 'lock version updated'diff --git a/spec/services/projects/copy_service_integration_spec.rb b/spec/services/projects/copy_service_integration_spec.rbindex 1254a784632..645ef27c965 100644--- a/spec/services/projects/copy_service_integration_spec.rb+++ b/spec/services/projects/copy_service_integration_spec.rb@@ -672,7 +672,7 @@ describe Projects::CopyService, 'integration', type: :model dobefore docustom_fieldwork_package.reload- work_package.send(:"custom_field_#{custom_field.id}=", current_user.id)+ work_package.send(custom_field.attribute_setter, current_user.id)work_package.save!(validate: false)end@@ -682,7 +682,7 @@ describe Projects::CopyService, 'integration', type: :model doit 'copies the custom_field' doexpect(subject).to be_successwp = project_copy.work_packages.find_by(subject: work_package.subject)- expect(wp.send(:"custom_field_#{custom_field.id}"))+ expect(wp.send(custom_field.attribute_getter)).to eql current_userendend@@ -693,7 +693,7 @@ describe Projects::CopyService, 'integration', type: :model doit 'nils the custom_field' doexpect(subject).to be_successwp = project_copy.work_packages.find_by(subject: work_package.subject)- expect(wp.send(:"custom_field_#{custom_field.id}"))+ expect(wp.send(custom_field.attribute_getter)).to be_nilendenddiff --git a/spec/services/projects/update_service_integration_spec.rb b/spec/services/projects/update_service_integration_spec.rbindex 7c2a3ac3247..2011e50d7e4 100644--- a/spec/services/projects/update_service_integration_spec.rb+++ b/spec/services/projects/update_service_integration_spec.rb@@ -44,7 +44,7 @@ describe Projects::UpdateService, 'integration', type: :model dolet!(:project) docreate(:project,- "custom_field_#{custom_field.id}" => 1,+ custom_field.attribute_name => 1,status: project_status)endlet(:instance) { described_class.new(user:, model: project) }@@ -60,7 +60,7 @@ describe Projects::UpdateService, 'integration', type: :model dodescribe '#call' docontext 'if only a custom field is updated' dolet(:attributes) do- { "custom_field_#{custom_field.id}" => 8 }+ { custom_field.attribute_name => 8 }endit 'touches the project after saving' do@@ -79,7 +79,7 @@ describe Projects::UpdateService, 'integration', type: :model dolet(:custom_field2) { create(:text_project_custom_field) }let(:attributes) do- { "custom_field_#{custom_field2.id}" => 'some text' }+ { custom_field2.attribute_name => 'some text' }endit 'touches the project after saving' dodiff --git a/spec/services/shared_type_service.rb b/spec/services/shared_type_service.rbindex 3c3715be6bb..391a53a83fc 100644--- a/spec/services/shared_type_service.rb+++ b/spec/services/shared_type_service.rb@@ -36,10 +36,10 @@ shared_context 'with custom field params' doattribute_groups: [{ 'type' => 'attribute','name' => 'group1',- 'attributes' => [{ 'key' => "custom_field_#{cf1.id}" }, { 'key' => "custom_field_#{cf2.id}" }] },+ 'attributes' => [{ 'key' => cf1.attribute_name }, { 'key' => cf2.attribute_name }] },{ 'type' => 'attribute','name' => 'groups',- 'attributes' => [{ 'key' => "custom_field_#{cf2.id}" }] }+ 'attributes' => [{ 'key' => cf2.attribute_name }] }]}end@@ -138,7 +138,7 @@ shared_examples_for 'type service' doit 'enables the custom fields that are passed via attribute_groups' doallow(type).to receive(:work_package_attributes)- .and_return("custom_field_#{cf1.id}" => {}, "custom_field_#{cf2.id}" => {})+ .and_return(cf1.attribute_name => {}, cf2.attribute_name => {})allow(type).to receive(:custom_field_ids=)diff --git a/spec/services/work_packages/update_service_integration_spec.rb b/spec/services/work_packages/update_service_integration_spec.rbindex 4a089c08461..8c18f4e54c7 100644--- a/spec/services/work_packages/update_service_integration_spec.rb+++ b/spec/services/work_packages/update_service_integration_spec.rb@@ -1253,7 +1253,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model, with_maparent:,start_date: Time.zone.today + 1.day,due_date: Time.zone.today + 5.days,- "custom_field_#{custom_field.id}": 5)+ custom_field.attribute_name => 5)endlet!(:attributes) { { parent: nil } }@@ -1264,7 +1264,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model, with_maproject:,type: project.types.first,parent:,- "custom_field_#{custom_field.id}": 8+ custom_field.attribute_name => 8}end@@ -1335,7 +1335,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model, with_ma{type:,project:,- "custom_field_#{custom_field_of_current_type.id}": 5+ custom_field_of_current_type.attribute_name => 5}enddiff --git a/spec/support/shared/acts_as_customizable.rb b/spec/support/shared/acts_as_customizable.rbindex 4fbcf4ccd61..e8d5be9a677 100644--- a/spec/support/shared/acts_as_customizable.rb+++ b/spec/support/shared/acts_as_customizable.rb@@ -45,7 +45,7 @@ shared_examples_for 'acts_as_customizable included' doit 'returns the field changes' domodel_instance.custom_field_values = { custom_field.id => 'test' }expect(model_instance.custom_field_changes)- .to eq({ "custom_field_#{custom_field.id}": [nil, 'test'] })+ .to eq({ custom_field.attribute_name.to_sym => [nil, 'test'] })endendend@@ -54,7 +54,7 @@ shared_examples_for 'acts_as_customizable included' doit 'returns the field changes' domodel_instance.custom_field_values = { custom_field.id => 'test' }expect(model_instance.custom_field_changes)- .to eq({ "custom_field_#{custom_field.id}": [nil, 'test'] })+ .to eq({ custom_field.attribute_name.to_sym => [nil, 'test'] })endend@@ -67,7 +67,7 @@ shared_examples_for 'acts_as_customizable included' doit 'returns the field changes' domodel_instance.custom_field_values = { custom_field.id => 'test2' }expect(model_instance.custom_field_changes)- .to eq({ "custom_field_#{custom_field.id}": ['test', 'test2'] })+ .to eq({ custom_field.attribute_name.to_sym => ['test', 'test2'] })endend@@ -92,7 +92,7 @@ shared_examples_for 'acts_as_customizable included' doit 'returns the field changes' domodel_instance.custom_field_values = { custom_field.id => nil }expect(model_instance.custom_field_changes)- .to eq({ "custom_field_#{custom_field.id}": ['test', nil] })+ .to eq({ custom_field.attribute_name.to_sym => ['test', nil] })endendend