]> source.dussan.org Git - redmine.git/commitdiff
Merged r7779 from trunk.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 29 Nov 2011 21:12:58 +0000 (21:12 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 29 Nov 2011 21:12:58 +0000 (21:12 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@7998 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/custom_value.rb
test/unit/custom_value_test.rb

index 97bd47f9459412d298248a5b5d1dc5ef2d0c10e2..f31ffee7ffcd4a013fa0d735ef3117a95dae320f 100644 (file)
@@ -62,7 +62,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
index 49ae28cec79664860d5cec0efd2bf0dd72eebad2..467d1f6c0ddfce6a606d9173d0a0aa06012233ad 100644 (file)
@@ -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