From 9b7efd00e89cf47bcb51877c658f2580533df900 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sat, 10 Nov 2018 23:02:47 +0000 Subject: [PATCH] Merged r17625 from trunk to 3.4-stable (#8317). git-svn-id: http://svn.redmine.org/redmine/branches/3.4-stable@17627 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 fade7c257..497147388 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -486,7 +486,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.to_s =~ /^[+-]?\d+$/ + errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value.to_s.strip =~ /^[+-]?\d+$/ errs end diff --git a/test/unit/custom_field_test.rb b/test/unit/custom_field_test.rb index 3eae54efa..b49501ed0 100644 --- a/test/unit/custom_field_test.rb +++ b/test/unit/custom_field_test.rb @@ -206,6 +206,7 @@ class CustomFieldTest < ActiveSupport::TestCase assert f.valid_field_value?('') assert !f.valid_field_value?(' ') assert f.valid_field_value?('123') + assert f.valid_field_value?(' 123 ') assert f.valid_field_value?('+123') assert f.valid_field_value?('-123') assert !f.valid_field_value?('6abc') @@ -219,6 +220,7 @@ class CustomFieldTest < ActiveSupport::TestCase assert f.valid_field_value?('') assert !f.valid_field_value?(' ') assert f.valid_field_value?('11.2') + assert f.valid_field_value?(' 11.2 ') assert f.valid_field_value?('-6.250') assert f.valid_field_value?('5') assert !f.valid_field_value?('6abc') -- 2.39.5