1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Ensure that the comparison between 'CollectionProxy' and 'AssociationRelation' is consistent.

This commit is contained in:
Lauro Caetano 2014-04-11 20:09:30 -03:00
parent 24052f925f
commit 783982ab2d

View file

@ -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