Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't need to check if the scope respond to call

We are checking this when defining the default scope and raising an
ArgumentError
  • Loading branch information...
commit bf2c4280563ba5f86072c1bad8af27ff5e5da0f3 1 parent adbd04f
Rafael Mendonça França + Kassio Borges authored
View
6 activerecord/lib/active_record/scoping/default.rb
@@ -100,11 +100,7 @@ def build_default_scope # :nodoc:
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
+ default_scope.merge(unscoped { scope.call })
end
end
end
View
2  activerecord/test/cases/associations/nested_through_associations_test.rb
@@ -371,7 +371,7 @@ def test_joins_and_includes_from_through_models_not_included_in_association
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
View
2  activerecord/test/cases/dup_test.rb
@@ -126,7 +126,7 @@ def test_dup_validity_is_independent
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
Please sign in to comment.
Something went wrong with that request. Please try again.