diff options
author | Gannon McGibbon <gannon.mcgibbon@gmail.com> | 2017-07-08 01:31:22 +0300 |
---|---|---|
committer | Gannon McGibbon <gannon.mcgibbon@gmail.com> | 2018-12-12 12:02:12 -0500 |
commit | d126c0d6c0e8c0803a8ce79d2baece4d3d24e509 (patch) | |
tree | e7c5592ab2cf5e91833398b793ba50a686b08db7 /activemodel/test | |
parent | 0fc6804c7e385140976520fd4d1a269eb735160b (diff) | |
download | rails-d126c0d6c0e8c0803a8ce79d2baece4d3d24e509.tar.gz rails-d126c0d6c0e8c0803a8ce79d2baece4d3d24e509.tar.bz2 rails-d126c0d6c0e8c0803a8ce79d2baece4d3d24e509.zip |
Fix numericality equality validation on floats
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/validations/numericality_validation_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb index ca3c3bc40d..ca22e38c2d 100644 --- a/activemodel/test/cases/validations/numericality_validation_test.rb +++ b/activemodel/test/cases/validations/numericality_validation_test.rb @@ -289,6 +289,13 @@ class NumericalityValidationTest < ActiveModel::TestCase assert_raise(ArgumentError) { Topic.validates_numericality_of :approved, equal_to: "foo" } end + def test_validates_numericality_equality_for_float_and_big_decimal + Topic.validates_numericality_of :approved, equal_to: BigDecimal("65.6") + + invalid!([Float("65.5"), BigDecimal("65.7")], "must be equal to 65.6") + valid!([Float("65.6"), BigDecimal("65.6")]) + end + private def invalid!(values, error = nil) |