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
Remove aac patch custom_field_values= method
Dombi Attila0e01fb4f4a78
diff --git a/app/models/projects/acts_as_customizable_patches.rb b/app/models/projects/acts_as_customizable_patches.rbindex 00d7ad8b436..cdb7b29eac2 100644--- a/app/models/projects/acts_as_customizable_patches.rb+++ b/app/models/projects/acts_as_customizable_patches.rb@@ -100,11 +100,5 @@ module Projects::ActsAsCustomizablePatchescustom_field_valuesendend-- # we need to query the available custom fields on a global level when updating custom field values- # in order to support implicit activation of custom fields when values are provided during an update- def custom_field_values=(values)- with_all_available_custom_fields { super }- endendenddiff --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 9c432079993..cc23ec17cda 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@@ -98,7 +98,7 @@ module Redminereturn unless values.is_a?(Hash) && values.any?values.with_indifferent_access.each do |custom_field_id, val|- existing_cv_by_value = custom_values_for_custom_field(id: custom_field_id)+ existing_cv_by_value = custom_values_for_custom_field(id: custom_field_id, all: true).group_by(&:value).transform_values(&:first)new_values = Array(val).map { |v| v.respond_to?(:id) ? v.id.to_s : v.to_s }@@ -111,13 +111,14 @@ module Redmineendend- def custom_values_for_custom_field(id:)- custom_field_values.select { |cv| cv.custom_field_id == id.to_i }+ def custom_values_for_custom_field(id:, all: false)+ custom_field_values(all:).select { |cv| cv.custom_field_id == id.to_i }end- def custom_field_values- custom_field_values_cache[custom_field_cache_key] ||=- available_custom_fields.flat_map do |custom_field|+ def custom_field_values(all: false)+ custom_field_values_cache[custom_field_cache_key] ||= begin+ current_custom_fields = all ? all_available_custom_fields : available_custom_fields+ current_custom_fields.flat_map do |custom_field|existing_cvs = custom_values.select { |v| v.custom_field_id == custom_field.id }if existing_cvs.empty?@@ -126,6 +127,7 @@ module Redmineexisting_cvsendend+ endend# Returns the cache key for caching @custom_field_values_cache.diff --git a/spec/requests/api/v3/projects/update_resource_spec.rb b/spec/requests/api/v3/projects/update_resource_spec.rbindex 9a34d40a0cc..b9aa431487a 100644--- a/spec/requests/api/v3/projects/update_resource_spec.rb+++ b/spec/requests/api/v3/projects/update_resource_spec.rb@@ -47,11 +47,6 @@ RSpec.describe "API v3 Project resource update", content_type: :json dolet(:invisible_custom_field) docreate(:text_project_custom_field, visible: false)end- let(:custom_value) do- CustomValue.create(custom_field:,- value: "1234",- customized: project)- endlet(:permissions) { [:edit_project] }let(:path) { api_v3_paths.project(project.id) }let(:body) do@@ -154,6 +149,17 @@ RSpec.describe "API v3 Project resource update", content_type: :json do.to be_emptyend+ context "when the hidden field has a value already" do+ it "does not change the cf value" do+ project.custom_field_values = { invisible_custom_field.id => "1234" }+ project.save+ patch path, body.to_json++ expect(project.reload.custom_values.find_by(custom_field: invisible_custom_field).value)+ .to eq "1234"+ end+ end+it "does not activate the cf for project" doexpect(project.reload.project_custom_fields).to be_empty