Patch #41827 » 0001_change_custom_field_name_limit.patch
| app/models/custom_field.rb | ||
|---|---|---|
|
|
||
|
validates_presence_of :name, :field_format
|
||
|
validates_uniqueness_of :name, :scope => :type, :case_sensitive => true
|
||
|
validates_length_of :name, :maximum => 30
|
||
|
validates_length_of :name, maximum: 255
|
||
|
validates_length_of :regexp, maximum: 255
|
||
|
validates_inclusion_of :field_format,
|
||
|
:in => proc {Redmine::FieldFormat.available_formats}
|
||
| /dev/null → db/migrate/20241016120800_change_custom_fields_name_limit.rb | ||
|---|---|---|
|
class ChangeCustomFieldsNameLimit < ActiveRecord::Migration[7.2]
|
||
|
def up
|
||
|
change_column :custom_fields, :name, :string, limit: 255, default: ''
|
||
|
end
|
||
|
|
||
|
def down
|
||
|
change_column :custom_fields, :name, :string, limit: 30, default: ''
|
||
|
end
|
||
|
end
|
||
| test/unit/custom_field_test.rb | ||
|---|---|---|
|
assert field.save
|
||
|
end
|
||
|
|
||
|
def test_name_should_be_validated
|
||
|
field = CustomField.new(name: 'Very long custom field name' * 10, field_format: 'int')
|
||
|
assert field.invalid?
|
||
|
end
|
||
|
|
||
|
def test_default_value_should_be_validated
|
||
|
field = CustomField.new(:name => 'Test', :field_format => 'int')
|
||
|
field.default_value = 'abc'
|
||
|
-
|
||