diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-20 17:49:47 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-20 17:49:47 -0600 |
commit | 12df3391e349711569ba0638cadc61445a8c627d (patch) | |
tree | 538e14be6fd3a8f90dc6798c73cadb496aa2d964 /activemodel/test | |
parent | ed8bcd6934d0f31c3318df69e12df03a3c81a453 (diff) | |
download | rails-12df3391e349711569ba0638cadc61445a8c627d.tar.gz rails-12df3391e349711569ba0638cadc61445a8c627d.tar.bz2 rails-12df3391e349711569ba0638cadc61445a8c627d.zip |
Fix test failures caused by #19851
The error message when asserting `greater_than: BigDecimal.new` will
give an error message based on how BigDecimal displays itself. Big
decimal appears to always use scientific notation. This might not be the
best error message for the general case, but the general case wouldn't
use big decimal for the validation. And if they do, they likely need
this level of precision.
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/validations/numericality_validation_test.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb index 4db6c828f8..5453719632 100644 --- a/activemodel/test/cases/validations/numericality_validation_test.rb +++ b/activemodel/test/cases/validations/numericality_validation_test.rb @@ -74,7 +74,7 @@ class NumericalityValidationTest < ActiveModel::TestCase def test_validates_numericality_with_greater_than_using_differing_numeric_types Topic.validates_numericality_of :approved, greater_than: BigDecimal.new('97.18') - invalid!([-97.18, BigDecimal.new('97.18'), BigDecimal('-97.18')], 'must be greater than 97.18') + invalid!([-97.18, BigDecimal.new('97.18'), BigDecimal('-97.18')], 'must be greater than 0.9718E2') valid!([97.18, 98, BigDecimal.new('98')]) # Notice the 97.18 as a float is greater than 97.18 as a BigDecimal due to floating point precision end @@ -88,7 +88,7 @@ class NumericalityValidationTest < ActiveModel::TestCase def test_validates_numericality_with_greater_than_or_equal_using_differing_numeric_types Topic.validates_numericality_of :approved, greater_than_or_equal_to: BigDecimal.new('97.18') - invalid!([-97.18, 97.17, 97, BigDecimal.new('97.17'), BigDecimal.new('-97.18')], 'must be greater than or equal to 97.18') + invalid!([-97.18, 97.17, 97, BigDecimal.new('97.17'), BigDecimal.new('-97.18')], 'must be greater than or equal to 0.9718E2') valid!([97.18, 98, BigDecimal.new('97.19')]) end @@ -102,7 +102,7 @@ class NumericalityValidationTest < ActiveModel::TestCase def test_validates_numericality_with_equal_to_using_differing_numeric_types Topic.validates_numericality_of :approved, equal_to: BigDecimal.new('97.18') - invalid!([-97.18, 97.18], 'must be equal to 97.18') + invalid!([-97.18, 97.18], 'must be equal to 0.9718E2') valid!([BigDecimal.new('97.18')]) end @@ -116,7 +116,7 @@ class NumericalityValidationTest < ActiveModel::TestCase def test_validates_numericality_with_less_than_using_differing_numeric_types Topic.validates_numericality_of :approved, less_than: BigDecimal.new('97.18') - invalid!([97.18, BigDecimal.new('97.18')], 'must be less than 97.18') + invalid!([97.18, BigDecimal.new('97.18')], 'must be less than 0.9718E2') valid!([-97.0, 97.0, -97, 97, BigDecimal.new('-97'), BigDecimal.new('97')]) end @@ -130,7 +130,7 @@ class NumericalityValidationTest < ActiveModel::TestCase def test_validates_numericality_with_less_than_or_equal_to_using_differing_numeric_types Topic.validates_numericality_of :approved, less_than_or_equal_to: BigDecimal.new('97.18') - invalid!([97.18, 98], 'must be less than or equal to 97.18') + invalid!([97.18, 98], 'must be less than or equal to 0.9718E2') valid!([-97.18, BigDecimal.new('-97.18'), BigDecimal.new('97.18')]) end |