mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Extract deprecated code
This commit is contained in:
parent
ef1d1e1492
commit
618c5fc3c0
2 changed files with 13 additions and 9 deletions
|
@ -29,17 +29,16 @@ module ActiveRecord
|
|||
# You can define a \scope that applies to all finders using
|
||||
# ActiveRecord::Base.default_scope.
|
||||
def scoped(options = nil)
|
||||
if options
|
||||
scoped.apply_finder_options(options)
|
||||
if current_scope
|
||||
scope = current_scope.clone
|
||||
else
|
||||
if current_scope
|
||||
current_scope.clone
|
||||
else
|
||||
scope = relation
|
||||
scope.default_scoped = true
|
||||
scope
|
||||
end
|
||||
scope = relation
|
||||
scope.default_scoped = true
|
||||
scope
|
||||
end
|
||||
|
||||
scope.merge!(options) if options
|
||||
scope
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -2087,4 +2087,9 @@ class BasicsTest < ActiveRecord::TestCase
|
|||
assert_equal record, klass.public_send(meth, :foo, :bar)
|
||||
end
|
||||
end
|
||||
|
||||
test "scoped can take a values hash" do
|
||||
klass = Class.new(ActiveRecord::Base)
|
||||
assert_equal ['foo'], klass.scoped(select: 'foo').select_values
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue