diff options
author | Go MAEDA <maeda@farend.jp> | 2018-11-08 13:01:06 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2018-11-08 13:01:06 +0000 |
commit | c5eff3dae254481d038fe482466d2075b63b0338 (patch) | |
tree | 739c8f7f70c418ac58007605b1c2cbc3b2f0bffa | |
parent | 54cfb7b75ede8736c8bee1a4aa88e098e1df3889 (diff) | |
download | redmine-c5eff3dae254481d038fe482466d2075b63b0338.tar.gz redmine-c5eff3dae254481d038fe482466d2075b63b0338.zip |
Strip whitespace from integer custom field (#8317).
Patch by Go MAEDA.
git-svn-id: http://svn.redmine.org/redmine/trunk@17625 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | lib/redmine/field_format.rb | 2 | ||||
-rw-r--r-- | test/unit/custom_field_test.rb | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb index 4d168b434..64fcdc6a4 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -490,7 +490,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 bdf5d4842..b1d7f7ad7 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') |