mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-10 17:41:31 +00:00
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
This commit is contained in:
parent
54cfb7b75e
commit
c5eff3dae2
@ -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
|
||||
|
||||
|
||||
@ -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')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user