Skip to content

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

Remove pending status from spec

Dombi Attilafce24a2e5916
diff --git a/app/models/custom_value.rb b/app/models/custom_value.rb
index d3b55b63bb0..4469a75ecee 100644
--- a/app/models/custom_value.rb
+++ b/app/models/custom_value.rb
@@ -73,7 +73,9 @@ class CustomValue < ApplicationRecord
# if a custom value is created for a project via CustomValue.create(...),
# the custom field needs to be activated in the project
- unless customized&.project_custom_fields&.include?(custom_field)
+ if customized&.available_custom_fields&.include?(custom_field) &&
+ customized&.project_custom_fields&.exclude?(custom_field)
+
customized.project_custom_fields << custom_field
end
end
diff --git a/app/models/projects/acts_as_customizable_patches.rb b/app/models/projects/acts_as_customizable_patches.rb
index c2a3d50206f..4669e1f95fd 100644
--- a/app/models/projects/acts_as_customizable_patches.rb
+++ b/app/models/projects/acts_as_customizable_patches.rb
@@ -49,8 +49,8 @@ module Projects::ActsAsCustomizablePatches
before_create :reject_section_scoped_validation_for_creation
before_create :build_missing_project_custom_field_project_mappings
+ after_create :disable_custom_fields_with_empty_values
after_save :reset_section_scoped_validation, :set_query_available_custom_fields_to_project_level
- before_commit :disable_custom_fields_with_empty_values, on: :create
def build_missing_project_custom_field_project_mappings
# activate custom fields for this project (via mapping table) if values have been provided for custom_fields but no mapping exists
diff --git a/spec/models/projects/customizable_spec.rb b/spec/models/projects/customizable_spec.rb
index c98354e24f2..6dc4d64fe22 100644
--- a/spec/models/projects/customizable_spec.rb
+++ b/spec/models/projects/customizable_spec.rb
@@ -462,27 +462,12 @@ RSpec.describe Project, "customizable" do
let(:user) { create(:user) }
it "does not activate hidden custom fields" do
- pending <<~REASON.squish
- Due to backward compatibility for the API,
- we have to activate the hidden_custom_field too,
- but it won't receive any value, so its value is not changed.
- The frontend will not send the hidden field anyway,
- so this behaviour does not present a real problem.
- REASON
# project creation happens with an non-admin user as let(:project) called after setting the current user to an non-admin
expect(project.project_custom_field_project_mappings.pluck(:custom_field_id))
.to contain_exactly(text_custom_field.id, bool_custom_field.id)
expect(project.custom_value_for(hidden_custom_field)).to be_nil
end
-
- it "does not set a value for the hidden custom fields" do
- # project creation happens with an non-admin user as let(:project) called after setting the current user to an non-admin
- expect(project.project_custom_field_project_mappings.pluck(:custom_field_id))
- .to contain_exactly(text_custom_field.id, bool_custom_field.id, hidden_custom_field.id)
-
- expect(project.custom_value_for(hidden_custom_field)).to be_nil
- end
end
end
end