From a77d884157439c226342e789f13bd6bfe8dd4227 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 10 Jan 2015 11:06:27 +0000 Subject: [PATCH] Fixed: Redmine::FieldFormat::IntFormat does not accept "real" Integer values (#18781). git-svn-id: http://svn.redmine.org/redmine/trunk@13863 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/field_format.rb | 2 +- test/unit/custom_field_test.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb index 34591bb5f..7ccc0ffc7 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -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 diff --git a/test/unit/custom_field_test.rb b/test/unit/custom_field_test.rb index c20d7f645..e1166c8c6 100644 --- a/test/unit/custom_field_test.rb +++ b/test/unit/custom_field_test.rb @@ -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 -- 2.39.5