From f6978c2eb42d31777329017b78a586e2b1d7ff71 Mon Sep 17 00:00:00 2001 From: kane Date: Sat, 4 Sep 2010 08:24:35 -0700 Subject: added a test for relation which checks intersection between a relation and an array works in both directions --- activerecord/test/cases/relations_test.rb | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index be038bf..836c725 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -667,4 +667,12 @@ class RelationTest < ActiveRecord::TestCase def test_relations_limit_with_conditions_or_limit assert_equal Post.limit(2).size, Post.limit(2).all.size end + + def test_intersection_with_array + relation = Book.where(:name => "Ruby for Rails") + rails_book = relation.first + + assert_equal [rails_book], [rails_book] & relation + assert_equal [rails_book], relation & [rails_book] + end end -- 1.6.3.3