aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/relations_test.rb14
1 files changed, 14 insertions, 0 deletions
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