Patch #41827 » 0001_change_custom_field_name_limit.patch
| app/models/custom_field.rb | ||
|---|---|---|
| 35 | 35 |
|
| 36 | 36 |
validates_presence_of :name, :field_format |
| 37 | 37 |
validates_uniqueness_of :name, :scope => :type, :case_sensitive => true |
| 38 |
validates_length_of :name, :maximum => 30
|
|
| 38 |
validates_length_of :name, maximum: 255
|
|
| 39 | 39 |
validates_length_of :regexp, maximum: 255 |
| 40 | 40 |
validates_inclusion_of :field_format, |
| 41 | 41 |
:in => proc {Redmine::FieldFormat.available_formats}
|
| /dev/null → db/migrate/20241016120800_change_custom_fields_name_limit.rb | ||
|---|---|---|
| 1 |
class ChangeCustomFieldsNameLimit < ActiveRecord::Migration[7.2] |
|
| 2 |
def up |
|
| 3 |
change_column :custom_fields, :name, :string, limit: 255, default: '' |
|
| 4 |
end |
|
| 5 |
|
|
| 6 |
def down |
|
| 7 |
change_column :custom_fields, :name, :string, limit: 30, default: '' |
|
| 8 |
end |
|
| 9 |
end |
|
| test/unit/custom_field_test.rb | ||
|---|---|---|
| 52 | 52 |
assert field.save |
| 53 | 53 |
end |
| 54 | 54 |
|
| 55 |
def test_name_should_be_validated |
|
| 56 |
field = CustomField.new(name: 'Very long custom field name' * 10, field_format: 'int') |
|
| 57 |
assert field.invalid? |
|
| 58 |
end |
|
| 59 |
|
|
| 55 | 60 |
def test_default_value_should_be_validated |
| 56 | 61 |
field = CustomField.new(:name => 'Test', :field_format => 'int') |
| 57 | 62 |
field.default_value = 'abc' |
| 58 |
- |
|