提交 61555a0d 编写于 作者: J Jon Leighton

allow AssociationProxy#scoped to take options so that API is the same as Base#scoped

上级 df6f971e
......@@ -61,11 +61,15 @@ def proxy_association
@association
end
def scoped
def scoped(options = nil)
association = @association
association.scoped.extending do
scope = association.scoped
scope.extending! do
define_method(:proxy_association) { association }
end
scope.merge!(options) if options
scope
end
def respond_to?(name, include_private = false)
......
......@@ -214,6 +214,10 @@ def test_proxy_association_accessor
david = developers(:david)
assert_equal david.association(:projects), david.projects.proxy_association
end
def test_scoped_allows_conditions
assert developers(:david).projects.scoped(where: 'foo').where_values.include?('foo')
end
end
class OverridingAssociationsTest < ActiveRecord::TestCase
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册