diff options
author | Lauro Caetano <laurocaetano1@gmail.com> | 2014-04-11 19:51:38 -0300 |
---|---|---|
committer | Lauro Caetano <laurocaetano1@gmail.com> | 2014-04-12 11:00:33 -0300 |
commit | 24052f925f5f52f74646610a843eb3b98845ac77 (patch) | |
tree | 8063f7b714d7257dec98fcace27b2944e3f8e49d /activerecord/test | |
parent | d6840f914a32bff4d73f23c3f5c64c5397f8b400 (diff) | |
download | rails-24052f925f5f52f74646610a843eb3b98845ac77.tar.gz rails-24052f925f5f52f74646610a843eb3b98845ac77.tar.bz2 rails-24052f925f5f52f74646610a843eb3b98845ac77.zip |
Make the comparison between 'Relation' and 'AssociationRelation'
consistent.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
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 |