diff options
author | namusyaka <namusyaka@gmail.com> | 2017-02-17 22:15:01 +0900 |
---|---|---|
committer | namusyaka <namusyaka@gmail.com> | 2017-02-18 19:04:48 +0900 |
commit | b0be7792adf58e092b7f615ecbf3339ea70ee689 (patch) | |
tree | 910c19f520e71fd5109a211a509252dfad36917f /activemodel/test/cases/validations | |
parent | 74689fda0ce7612d87c620a36097d2d7451f53c0 (diff) | |
download | rails-b0be7792adf58e092b7f615ecbf3339ea70ee689.tar.gz rails-b0be7792adf58e092b7f615ecbf3339ea70ee689.tar.bz2 rails-b0be7792adf58e092b7f615ecbf3339ea70ee689.zip |
Avoid converting integer as a string into float
Diffstat (limited to 'activemodel/test/cases/validations')
-rw-r--r-- | activemodel/test/cases/validations/numericality_validation_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb index a1be2de578..c0158e075f 100644 --- a/activemodel/test/cases/validations/numericality_validation_test.rb +++ b/activemodel/test/cases/validations/numericality_validation_test.rb @@ -260,6 +260,15 @@ class NumericalityValidationTest < ActiveModel::TestCase Person.clear_validators! end + def test_validates_numericality_with_exponent_number + base = 10_000_000_000_000_000 + Topic.validates_numericality_of :approved, less_than_or_equal_to: base + topic = Topic.new + topic.approved = (base + 1).to_s + + assert topic.invalid? + end + def test_validates_numericality_with_invalid_args assert_raise(ArgumentError) { Topic.validates_numericality_of :approved, greater_than_or_equal_to: "foo" } assert_raise(ArgumentError) { Topic.validates_numericality_of :approved, less_than_or_equal_to: "foo" } |