aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França + Kassio Borges <rafaelmfranca+kassioborgesm@gmail.com>2013-08-31 14:53:28 -0300
committerRafael Mendonça França + Kassio Borges <rafaelmfranca+kassioborgesm@gmail.com>2013-08-31 14:53:28 -0300
commitbf2c4280563ba5f86072c1bad8af27ff5e5da0f3 (patch)
tree5cd1483a8a43efbad3f81d8b7aafb81f36509f60
parentadbd04ff8026d7b920f887e82334657f4914ff04 (diff)
downloadrails-bf2c4280563ba5f86072c1bad8af27ff5e5da0f3.tar.gz
rails-bf2c4280563ba5f86072c1bad8af27ff5e5da0f3.tar.bz2
rails-bf2c4280563ba5f86072c1bad8af27ff5e5da0f3.zip
Don't need to check if the scope respond to call
We are checking this when defining the default scope and raising an ArgumentError
-rw-r--r--activerecord/lib/active_record/scoping/default.rb6
-rw-r--r--activerecord/test/cases/associations/nested_through_associations_test.rb2
-rw-r--r--activerecord/test/cases/dup_test.rb2
3 files changed, 3 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb
index a5d6aad3f0..01fec31544 100644
--- a/activerecord/lib/active_record/scoping/default.rb
+++ b/activerecord/lib/active_record/scoping/default.rb
@@ -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
+ default_scope.merge(unscoped { scope.call })
end
end
end
diff --git a/activerecord/test/cases/associations/nested_through_associations_test.rb b/activerecord/test/cases/associations/nested_through_associations_test.rb
index 9b1abc3b81..cf3c07845c 100644
--- a/activerecord/test/cases/associations/nested_through_associations_test.rb
+++ b/activerecord/test/cases/associations/nested_through_associations_test.rb
@@ -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
diff --git a/activerecord/test/cases/dup_test.rb b/activerecord/test/cases/dup_test.rb
index f73e449610..1e6ccecfab 100644
--- a/activerecord/test/cases/dup_test.rb
+++ b/activerecord/test/cases/dup_test.rb
@@ -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