Project

General

Profile

Defect #8317 ยป 8317-strip-spaces-int-cf.diff

Go MAEDA, 2017-04-15 05:45

View differences:

lib/redmine/field_format.rb (working copy)
486 486

  
487 487
      def validate_single_value(custom_field, value, customized=nil)
488 488
        errs = super
489
        errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value.to_s =~ /^[+-]?\d+$/
489
        errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value.to_s.strip =~ /^[+-]?\d+$/
490 490
        errs
491 491
      end
492 492

  
test/unit/custom_field_test.rb (working copy)
204 204
    assert f.valid_field_value?('')
205 205
    assert !f.valid_field_value?(' ')
206 206
    assert f.valid_field_value?('123')
207
    assert f.valid_field_value?(' 123 ')
207 208
    assert f.valid_field_value?('+123')
208 209
    assert f.valid_field_value?('-123')
209 210
    assert !f.valid_field_value?('6abc')
......
217 218
    assert f.valid_field_value?('')
218 219
    assert !f.valid_field_value?(' ')
219 220
    assert f.valid_field_value?('11.2')
221
    assert f.valid_field_value?(' 11.2 ')
220 222
    assert f.valid_field_value?('-6.250')
221 223
    assert f.valid_field_value?('5')
222 224
    assert !f.valid_field_value?('6abc')
    (1-1/1)