From ee7f66603573fd441f1522cc73ec0b7f56c4d1af Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sat, 14 Jan 2012 17:53:52 +0000 Subject: automatically add references when we can --- activerecord/test/cases/relations_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index c089ed164c..a652a52f38 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1175,4 +1175,18 @@ class RelationTest < ActiveRecord::TestCase scope = Post.references(:comments) assert !scope.eager_loading? end + + def test_automatically_added_references + scope = Post.where(:comments => { :body => "Bla" }) + assert_equal [:comments], scope.references_values + + scope = Post.where('comments.body' => 'Bla') + assert_equal [:comments], scope.references_values + + scope = Post.having(:comments => { :body => "Bla" }) + assert_equal [:comments], scope.references_values + + scope = Post.having('comments.body' => 'Bla') + assert_equal [:comments], scope.references_values + end end -- cgit v1.2.3