Custom date field accepts invalid dates (#9394).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7779 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
55b2ca8170
commit
981a6223e4
|
@ -64,7 +64,7 @@ protected
|
|||
when 'float'
|
||||
begin; Kernel.Float(value); rescue; errors.add(:value, :invalid) end
|
||||
when 'date'
|
||||
errors.add(:value, :not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/
|
||||
errors.add(:value, :not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/ && begin; value.to_date; rescue; false end
|
||||
when 'list'
|
||||
errors.add(:value, :inclusion) unless custom_field.possible_values.include?(value)
|
||||
end
|
||||
|
|
|
@ -64,6 +64,8 @@ class CustomValueTest < ActiveSupport::TestCase
|
|||
assert v.valid?
|
||||
v.value = 'abc'
|
||||
assert !v.valid?
|
||||
v.value = '1975-07-33'
|
||||
assert !v.valid?
|
||||
v.value = '1975-07-14'
|
||||
assert v.valid?
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue