aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/finder_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-01-29 08:34:33 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-01-29 09:24:14 +0900
commit159b21b59dba120e58eeb8bff89b9d322e720c44 (patch)
tree4961855b5e5d01f0dd9332869f94539b81422caa /activerecord/test/cases/finder_test.rb
parent6b8c161fc2cabdadd33826d21f9bd099041b8069 (diff)
downloadrails-159b21b59dba120e58eeb8bff89b9d322e720c44.tar.gz
rails-159b21b59dba120e58eeb8bff89b9d322e720c44.tar.bz2
rails-159b21b59dba120e58eeb8bff89b9d322e720c44.zip
Fix expanding an array of `composed_of` objects which have multiple mappings
Follow up of #31724. If `composed_of` objects have multiple mappings, array predicate handler can not correctly handle the expanded condition. We need to handle it like polymorphic association objects.
Diffstat (limited to 'activerecord/test/cases/finder_test.rb')
-rw-r--r--activerecord/test/cases/finder_test.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index fabfc4574c..b413212e26 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -868,13 +868,14 @@ class FinderTest < ActiveRecord::TestCase
assert_equal customers(:david), found_customer
end
- def test_hash_condition_find_with_aggregate_having_three_mapping_array
+ def test_hash_condition_find_with_aggregate_having_three_mappings_array
david_address = customers(:david).address
zaphod_address = customers(:zaphod).address
+ barney_address = customers(:barney).address
assert_kind_of Address, david_address
assert_kind_of Address, zaphod_address
- found_customers = Customer.where(address: [david_address, zaphod_address])
- assert_equal [customers(:david), customers(:zaphod)], found_customers
+ found_customers = Customer.where(address: [david_address, zaphod_address, barney_address])
+ assert_equal [customers(:david), customers(:zaphod), customers(:barney)], found_customers.sort_by(&:id)
end
def test_hash_condition_find_with_aggregate_having_one_mapping_array
@@ -883,7 +884,7 @@ class FinderTest < ActiveRecord::TestCase
assert_kind_of Money, david_balance
assert_kind_of Money, zaphod_balance
found_customers = Customer.where(balance: [david_balance, zaphod_balance])
- assert_equal [customers(:david), customers(:zaphod)], found_customers
+ assert_equal [customers(:david), customers(:zaphod)], found_customers.sort_by(&:id)
end
def test_hash_condition_find_with_aggregate_attribute_having_same_name_as_field_and_key_value_being_aggregate