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

exclude field_format in CustomFields::UpdateService params

Ivan Kuchina4b68df4778e
diff --git a/app/services/custom_fields/update_service.rb b/app/services/custom_fields/update_service.rb
index 504ec0339b4..93b63b97107 100644
--- a/app/services/custom_fields/update_service.rb
+++ b/app/services/custom_fields/update_service.rb
@@ -40,6 +40,10 @@ module CustomFields
private
+ def set_attributes_params(params)
+ super.except(:field_format)
+ end
+
def recalculate_values
return unless recalculate_values?
diff --git a/spec/services/custom_fields/update_service_spec.rb b/spec/services/custom_fields/update_service_spec.rb
index 01317b9a6d6..d211614ced4 100644
--- a/spec/services/custom_fields/update_service_spec.rb
+++ b/spec/services/custom_fields/update_service_spec.rb
@@ -52,6 +52,19 @@ RSpec.describe CustomFields::UpdateService, type: :model do
allow(contract_class).to receive(:new).with(custom_field, user, options: {}).and_return(contract_instance)
end
+ describe "field_format attribute" do
+ context "when trying to change it" do
+ let!(:custom_field) { create(:boolean_wp_custom_field) }
+ let(:attributes) { { field_format: "text" } }
+
+ it "is ignored" do
+ expect(subject).to be_success
+
+ expect(custom_field.reload).to have_attributes(field_format: "bool")
+ end
+ end
+ end
+
describe "calculated value custom field", with_flag: { calculated_value_project_attribute: true } do
shared_let(:project1) { create(:project) }
shared_let(:project2) { create(:project) }