mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't need to check if the scope respond to call
We are checking this when defining the default scope and raising an ArgumentError
This commit is contained in:
parent
adbd04ff80
commit
bf2c428056
3 changed files with 3 additions and 7 deletions
|
@ -100,11 +100,7 @@ module ActiveRecord
|
|||
elsif default_scopes.any?
|
||||
evaluate_default_scope do
|
||||
default_scopes.inject(relation) do |default_scope, scope|
|
||||
if !scope.is_a?(Relation) && scope.respond_to?(:call)
|
||||
default_scope.merge(unscoped { scope.call })
|
||||
else
|
||||
default_scope.merge(scope)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -371,7 +371,7 @@ class NestedThroughAssociationsTest < ActiveRecord::TestCase
|
|||
prev_default_scope = Club.default_scopes
|
||||
|
||||
[:includes, :preload, :joins, :eager_load].each do |q|
|
||||
Club.default_scopes = [Club.send(q, :category)]
|
||||
Club.default_scopes = [proc { Club.send(q, :category) }]
|
||||
assert_equal categories(:general), members(:groucho).reload.club_category
|
||||
end
|
||||
ensure
|
||||
|
|
|
@ -126,7 +126,7 @@ module ActiveRecord
|
|||
|
||||
def test_dup_with_default_scope
|
||||
prev_default_scopes = Topic.default_scopes
|
||||
Topic.default_scopes = [Topic.where(:approved => true)]
|
||||
Topic.default_scopes = [proc { Topic.where(:approved => true) }]
|
||||
topic = Topic.new(:approved => false)
|
||||
assert !topic.dup.approved?, "should not be overridden by default scopes"
|
||||
ensure
|
||||
|
|
Loading…
Reference in a new issue