Commit 465e075b authored by jplang's avatar jplang

Make sure that custom field format cannot be changed.

git-svn-id: https://svn.redmine.org/redmine/trunk@10624 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 064c8ce2
......@@ -53,6 +53,11 @@ class CustomField < ActiveRecord::Base
CUSTOM_FIELDS_NAMES = CUSTOM_FIELDS_TABS.collect{|v| v[:name]}
def field_format=(arg)
# cannot change format of a saved custom field
super if new_record?
end
def set_searchable
# make sure these fields are not searchable
self.searchable = false if %w(int float date bool).include?(field_format)
......
......@@ -57,6 +57,12 @@ class CustomFieldTest < ActiveSupport::TestCase
assert field.valid?
end
def test_should_not_change_field_format_of_existing_custom_field
field = CustomField.find(1)
field.field_format = 'int'
assert_equal 'list', field.field_format
end
def test_possible_values_should_accept_an_array
field = CustomField.new
field.possible_values = ["One value", ""]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment