From 24052f925f5f52f74646610a843eb3b98845ac77 Mon Sep 17 00:00:00 2001 From: Lauro Caetano Date: Fri, 11 Apr 2014 19:51:38 -0300 Subject: Make the comparison between 'Relation' and 'AssociationRelation' consistent. --- activerecord/test/cases/base_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index d253b94b10..b428605b9d 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -568,6 +568,15 @@ class BasicsTest < ActiveRecord::TestCase assert Bulb.where(car_id: car.id) == car.bulbs.to_a, 'Relation should be comparable with Array' end + def test_equality_of_relation_and_association_relation + car = Car.create! + car.bulbs.build + car.save + + assert_equal Bulb.where(car_id: car.id), car.bulbs.includes(:car), 'Relation should be comparable with AssociationRelation' + assert_equal car.bulbs.includes(:car), Bulb.where(car_id: car.id), 'AssociationRelation should be comparable with Relation' + end + def test_hashing assert_equal [ Topic.find(1) ], [ Topic.find(2).topic ] & [ Topic.find(1) ] end -- cgit v1.2.3