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

block CustomField field_format from changing

Ivan Kuchin4f796ef2f7f9
diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb
index 2dd7a8ffa81..bf62ae8c013 100644
--- a/app/models/custom_field.rb
+++ b/app/models/custom_field.rb
@@ -49,6 +49,8 @@ class CustomField < ApplicationRecord
dependent: :destroy,
inverse_of: "custom_field"
+ attr_readonly :field_format
+
scope :hierarchy_root_and_children, -> { includes(hierarchy_root: { children: :children }) }
scope :required, -> { where(is_required: true) }
diff --git a/spec/models/custom_field_spec.rb b/spec/models/custom_field_spec.rb
index 2b28935f2d6..7b243742ea7 100644
--- a/spec/models/custom_field_spec.rb
+++ b/spec/models/custom_field_spec.rb
@@ -38,6 +38,8 @@ RSpec.describe CustomField do
let(:field) { build(:custom_field) }
let(:field2) { build(:custom_field) }
+ it { is_expected.to have_readonly_attribute(:field_format) }
+
describe "#name" do
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_length_of(:name).is_at_most(256) }