Permalink
Browse files

CollectionProxy should be default scoped

Fixes #8795
  • Loading branch information...
jonleighton committed Jan 18, 2013
1 parent e8d80f7 commit 5f759ff063b8ed054cdde0ed4f3593ef89fe59b7
@@ -33,6 +33,7 @@ class CollectionProxy < Relation
def initialize(klass, association) #:nodoc:
@association = association
super klass, klass.arel_table
+ self.default_scoped = true
merge! association.scope(nullify: false)
end
@@ -1712,4 +1712,9 @@ def test_collection_association_with_private_kernel_method
assert_equal 0, post.comments.count
end
end
+
+ test "collection proxy respects default scope" do
+ author = authors(:mary)
+ assert !author.first_posts.exists?
+ end
end

0 comments on commit 5f759ff

Please sign in to comment.