aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/eager_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/associations/eager_test.rb')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index 1dc71ac4cc..bf01b46852 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -1010,6 +1010,18 @@ class EagerAssociationTest < ActiveRecord::TestCase
end
end
+ def test_preload_has_many_with_association_condition_and_default_scope
+ post = Post.create!(:title => 'Beaches', :body => "I like beaches!")
+ Reader.create! :person => people(:david), :post => post
+ LazyReader.create! :person => people(:susan), :post => post
+
+ assert_equal 1, post.lazy_readers.to_a.size
+ assert_equal 2, post.lazy_readers_skimmers_or_not.to_a.size
+
+ post_with_readers = Post.includes(:lazy_readers_skimmers_or_not).find(post.id)
+ assert_equal 2, post_with_readers.lazy_readers_skimmers_or_not.to_a.size
+ end
+
def test_include_has_many_using_primary_key
expected = Firm.find(1).clients_using_primary_key.sort_by(&:name)
# Oracle adapter truncates alias to 30 characters