aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-11-12 03:39:28 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-11-12 03:39:28 +0900
commita741208f80dd33420a56486bd9ed2b0b9862234a (patch)
treed718f93e317084e299379b134135d600520150ea /activerecord/test
parent44bee7f242da1df49a31416b762e0a03467ae2bb (diff)
downloadrails-a741208f80dd33420a56486bd9ed2b0b9862234a.tar.gz
rails-a741208f80dd33420a56486bd9ed2b0b9862234a.tar.bz2
rails-a741208f80dd33420a56486bd9ed2b0b9862234a.zip
Ensure casting by decimal attribute when querying
Related 34cc301f03aea2e579d6687a9ea9782afc1089a0. `QueryAttribute#value_for_database` calls only `type.serialize`, and `Decimal#serialize` is a no-op unlike other attribute types. Whether or not `serialize` will invoke `cast` is undefined in our test cases, but it actually does not work properly unless it does so for now.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/numeric_data_test.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/activerecord/test/cases/numeric_data_test.rb b/activerecord/test/cases/numeric_data_test.rb
index 304714979c..079e664ee4 100644
--- a/activerecord/test/cases/numeric_data_test.rb
+++ b/activerecord/test/cases/numeric_data_test.rb
@@ -24,7 +24,10 @@ class NumericDataTest < ActiveRecord::TestCase
)
assert m.save
- m1 = NumericData.find(m.id)
+ m1 = NumericData.find_by(
+ bank_balance: 1586.43,
+ big_bank_balance: BigDecimal("1000234000567.95")
+ )
assert_kind_of Integer, m1.world_population
assert_equal 2**62, m1.world_population
@@ -48,7 +51,10 @@ class NumericDataTest < ActiveRecord::TestCase
)
assert m.save
- m1 = NumericData.find(m.id)
+ m1 = NumericData.find_by(
+ bank_balance: 1586.43122334,
+ big_bank_balance: BigDecimal("234000567.952344")
+ )
assert_kind_of Integer, m1.world_population
assert_equal 2**62, m1.world_population