Skip to content

Commit 1538959

Browse files
committed
Just check the BigDecimal 3.1+ behavior at NumericalityValidationTest
To prepare Ruby 3.4 will ship `bigdecimal` as bundled gem, `bigdecimal` has been added to Active Support runtime dependency via rails#49039 It will install BigDecimal version 3.1.4 or higher, so we just check the BigDecimal 3.1+ behavior at `NumericalityValidationTest`. Refer to rails#49039 ruby/bigdecimal#180 ruby/bigdecimal#70
1 parent ca374bd commit 1538959

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

activerecord/test/cases/validations/numericality_validation_test.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,9 @@ def test_virtual_attribute_with_precision_round_half_even
112112

113113
subject = model_class.new(virtual_decimal_number: 123.455)
114114

115-
if 123.455.to_d(5) == BigDecimal("123.46")
116-
# BigDecimal's to_d behavior changed in BigDecimal 3.0.1, see https://github.com/ruby/bigdecimal/issues/70
117-
# TODO: replace this with a check against BigDecimal::VERSION, currently
118-
# we just check the behavior because both versions of BigDecimal report "3.0.0"
119-
assert_not_predicate subject, :valid?
120-
else
121-
assert_predicate subject, :valid?
122-
end
115+
# BigDecimal's to_d behavior changed in BigDecimal 3.1.0, see https://github.com/ruby/bigdecimal/issues/70
116+
# Since BigDecimal 3.1.4 or higher is installed as an Active Support dependency, we just check the behavior of BigDecimal 3.1.0+.
117+
assert_not_predicate subject, :valid?
123118
end
124119

125120
def test_virtual_attribute_with_precision_round_up

0 commit comments

Comments
 (0)