Do not validate blank default custom field value.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8722 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-01-29 21:09:44 +00:00
parent cd6db6a3cb
commit 8d5f932660
2 changed files with 6 additions and 1 deletions

View File

@ -57,7 +57,7 @@ class CustomField < ActiveRecord::Base
end end
end end
unless valid_field_value?(default_value) if default_value.present? && !valid_field_value?(default_value)
errors.add(:default_value, :invalid) errors.add(:default_value, :invalid)
end end
end end

View File

@ -52,6 +52,11 @@ class CustomFieldTest < ActiveSupport::TestCase
assert field.valid? assert field.valid?
end end
def test_default_value_should_not_be_validated_when_blank
field = CustomField.new(:name => 'Test', :field_format => 'list', :possible_values => ['a', 'b'], :is_required => true, :default_value => '')
assert field.valid?
end
def test_possible_values_should_accept_an_array def test_possible_values_should_accept_an_array
field = CustomField.new field = CustomField.new
field.possible_values = ["One value", ""] field.possible_values = ["One value", ""]