aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorLauro Caetano <laurocaetano1@gmail.com>2014-04-11 20:09:30 -0300
committerLauro Caetano <laurocaetano1@gmail.com>2014-04-12 11:00:57 -0300
commit783982ab2df7a65e97d098ac1ab624436eb7c278 (patch)
treef2fa9f28fa13748a88d313e9e6209a5f534729a2 /activerecord/test/cases
parent24052f925f5f52f74646610a843eb3b98845ac77 (diff)
downloadrails-783982ab2df7a65e97d098ac1ab624436eb7c278.tar.gz
rails-783982ab2df7a65e97d098ac1ab624436eb7c278.tar.bz2
rails-783982ab2df7a65e97d098ac1ab624436eb7c278.zip
Ensure that the comparison between 'CollectionProxy' and 'AssociationRelation' is consistent.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/base_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index b428605b9d..2e5b8cffa6 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -577,6 +577,15 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal car.bulbs.includes(:car), Bulb.where(car_id: car.id), 'AssociationRelation should be comparable with Relation'
end
+ def test_equality_of_collection_proxy_and_association_relation
+ car = Car.create!
+ car.bulbs.build
+ car.save
+
+ assert_equal car.bulbs, car.bulbs.includes(:car), 'CollectionProxy should be comparable with AssociationRelation'
+ assert_equal car.bulbs.includes(:car), car.bulbs, 'AssociationRelation should be comparable with CollectionProxy'
+ end
+
def test_hashing
assert_equal [ Topic.find(1) ], [ Topic.find(2).topic ] & [ Topic.find(1) ]
end