]> source.dussan.org Git - redmine.git/commitdiff
Fixed: Redmine::FieldFormat::IntFormat does not accept "real" Integer values (#18781).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 10 Jan 2015 11:06:27 +0000 (11:06 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 10 Jan 2015 11:06:27 +0000 (11:06 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13863 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/field_format.rb
test/unit/custom_field_test.rb

index 34591bb5fff2facd8df2e3b432eda3984e106a2e..7ccc0ffc7cb212cc48e5b66abd6c006045757a7c 100644 (file)
@@ -368,7 +368,7 @@ module Redmine
 
       def validate_single_value(custom_field, value, customized=nil)
         errs = super
-        errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value =~ /^[+-]?\d+$/
+        errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value.to_s =~ /^[+-]?\d+$/
         errs
       end
 
index c20d7f6455fcfa2f47ffcd14b1959808783d3ac4..e1166c8c6b263f4766ba7495f116b300aac4a7ea 100644 (file)
@@ -193,6 +193,7 @@ class CustomFieldTest < ActiveSupport::TestCase
     assert f.valid_field_value?('+123')
     assert f.valid_field_value?('-123')
     assert !f.valid_field_value?('6abc')
+    assert f.valid_field_value?(123)
   end
 
   def test_float_field_validation
@@ -205,6 +206,7 @@ class CustomFieldTest < ActiveSupport::TestCase
     assert f.valid_field_value?('-6.250')
     assert f.valid_field_value?('5')
     assert !f.valid_field_value?('6abc')
+    assert f.valid_field_value?(11.2)
   end
 
   def test_multi_field_validation