aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/validations/numericality_validation_test.rb
diff options
context:
space:
mode:
authorYasuo Honda <yasuo.honda@gmail.com>2017-12-14 18:58:40 +0000
committerYasuo Honda <yasuo.honda@gmail.com>2017-12-14 19:00:00 +0000
commitbd4211ea1318aed28b3d5e784e09f23efb377236 (patch)
tree4cef037b664dc26b73bbbab44882d4c62a6d7ded /activemodel/test/cases/validations/numericality_validation_test.rb
parent659c516bef2781cc66865fc78ed5dce682566d26 (diff)
downloadrails-bd4211ea1318aed28b3d5e784e09f23efb377236.tar.gz
rails-bd4211ea1318aed28b3d5e784e09f23efb377236.tar.bz2
rails-bd4211ea1318aed28b3d5e784e09f23efb377236.zip
Suppress `warning: BigDecimal.new is deprecated` in Active Model
`BigDecimal.new` has been deprecated in BigDecimal 1.3.3 which will be a default for Ruby 2.5. Refer ruby/bigdecimal@5337373 * This commit has been made as follows: ```ruby $ cd activemodel/ $ git grep -l BigDecimal.new | grep \.rb | xargs sed -i -e "s/BigDecimal.new/BigDecimal/g" ``` * This commit has been tested with these Ruby versions: ``` ruby 2.5.0dev (2017-12-15 trunk 61262) [x86_64-linux] ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux] ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux] ruby 2.2.8p477 (2017-09-14 revision 59906) [x86_64-linux] ```
Diffstat (limited to 'activemodel/test/cases/validations/numericality_validation_test.rb')
-rw-r--r--activemodel/test/cases/validations/numericality_validation_test.rb28
1 files changed, 14 insertions, 14 deletions
diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb
index fbbaf8a30c..5413255e6b 100644
--- a/activemodel/test/cases/validations/numericality_validation_test.rb
+++ b/activemodel/test/cases/validations/numericality_validation_test.rb
@@ -20,7 +20,7 @@ class NumericalityValidationTest < ActiveModel::TestCase
INTEGER_STRINGS = %w(0 +0 -0 10 +10 -10 0090 -090)
FLOATS = [0.0, 10.0, 10.5, -10.5, -0.0001] + FLOAT_STRINGS
INTEGERS = [0, 10, -10] + INTEGER_STRINGS
- BIGDECIMAL = BIGDECIMAL_STRINGS.collect! { |bd| BigDecimal.new(bd) }
+ BIGDECIMAL = BIGDECIMAL_STRINGS.collect! { |bd| BigDecimal(bd) }
JUNK = ["not a number", "42 not a number", "0xdeadbeef", "0xinvalidhex", "0Xdeadbeef", "00-1", "--3", "+-3", "+3-1", "-+019.0", "12.12.13.12", "123\nnot a number"]
INFINITY = [1.0 / 0.0]
@@ -81,10 +81,10 @@ class NumericalityValidationTest < ActiveModel::TestCase
end
def test_validates_numericality_with_greater_than_using_differing_numeric_types
- Topic.validates_numericality_of :approved, greater_than: BigDecimal.new("97.18")
+ Topic.validates_numericality_of :approved, greater_than: BigDecimal("97.18")
- invalid!([-97.18, BigDecimal.new("97.18"), BigDecimal("-97.18")], "must be greater than 97.18")
- valid!([97.19, 98, BigDecimal.new("98"), BigDecimal.new("97.19")])
+ invalid!([-97.18, BigDecimal("97.18"), BigDecimal("-97.18")], "must be greater than 97.18")
+ valid!([97.19, 98, BigDecimal("98"), BigDecimal("97.19")])
end
def test_validates_numericality_with_greater_than_using_string_value
@@ -102,10 +102,10 @@ class NumericalityValidationTest < ActiveModel::TestCase
end
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")
+ Topic.validates_numericality_of :approved, greater_than_or_equal_to: BigDecimal("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")
- valid!([97.18, 98, BigDecimal.new("97.19")])
+ invalid!([-97.18, 97.17, 97, BigDecimal("97.17"), BigDecimal("-97.18")], "must be greater than or equal to 97.18")
+ valid!([97.18, 98, BigDecimal("97.19")])
end
def test_validates_numericality_with_greater_than_or_equal_using_string_value
@@ -123,10 +123,10 @@ class NumericalityValidationTest < ActiveModel::TestCase
end
def test_validates_numericality_with_equal_to_using_differing_numeric_types
- Topic.validates_numericality_of :approved, equal_to: BigDecimal.new("97.18")
+ Topic.validates_numericality_of :approved, equal_to: BigDecimal("97.18")
invalid!([-97.18], "must be equal to 97.18")
- valid!([BigDecimal.new("97.18")])
+ valid!([BigDecimal("97.18")])
end
def test_validates_numericality_with_equal_to_using_string_value
@@ -144,10 +144,10 @@ class NumericalityValidationTest < ActiveModel::TestCase
end
def test_validates_numericality_with_less_than_using_differing_numeric_types
- Topic.validates_numericality_of :approved, less_than: BigDecimal.new("97.18")
+ Topic.validates_numericality_of :approved, less_than: BigDecimal("97.18")
- invalid!([97.18, BigDecimal.new("97.18")], "must be less than 97.18")
- valid!([-97.0, 97.0, -97, 97, BigDecimal.new("-97"), BigDecimal.new("97")])
+ invalid!([97.18, BigDecimal("97.18")], "must be less than 97.18")
+ valid!([-97.0, 97.0, -97, 97, BigDecimal("-97"), BigDecimal("97")])
end
def test_validates_numericality_with_less_than_using_string_value
@@ -165,10 +165,10 @@ class NumericalityValidationTest < ActiveModel::TestCase
end
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")
+ Topic.validates_numericality_of :approved, less_than_or_equal_to: BigDecimal("97.18")
invalid!([97.19, 98], "must be less than or equal to 97.18")
- valid!([-97.18, BigDecimal.new("-97.18"), BigDecimal.new("97.18")])
+ valid!([-97.18, BigDecimal("-97.18"), BigDecimal("97.18")])
end
def test_validates_numericality_with_less_than_or_equal_using_string_value