Skip to content
Browse files

giving a hash to default scope should not be deprecated (well, not fo…

…r this reason)
  • Loading branch information...
1 parent 2970e3f commit 408437334bcb5df8d8daf7b60c13d496222954d2 @jonleighton jonleighton committed Apr 22, 2012
View
2 activerecord/lib/active_record/scoping/default.rb
@@ -90,7 +90,7 @@ def before_remove_const #:nodoc:
def default_scope(scope = {})
scope = Proc.new if block_given?
- if scope.is_a?(Relation) || !scope.respond_to?(:call)
+ if scope.is_a?(Relation) || !scope.is_a?(Hash) && !scope.respond_to?(:call)
ActiveSupport::Deprecation.warn(
"Calling #default_scope without a block is deprecated. For example instead " \
"of `default_scope where(color: 'red')`, please use " \
View
4 activerecord/test/cases/named_scope_test.rb
@@ -470,11 +470,11 @@ def test_eager_scopes_are_deprecated
assert_equal [posts(:welcome).title], klass.welcome_2.map(&:title)
end
- def test_eager_default_scope_hashes_are_deprecated
+ def test_eager_default_scope_hashes_are_not_deprecated
klass = Class.new(ActiveRecord::Base)
klass.table_name = 'posts'
- assert_deprecated do
+ assert_not_deprecated do
klass.send(:default_scope, :conditions => { :id => posts(:welcome).id })
end
assert_equal [posts(:welcome).title], klass.all.map(&:title)

0 comments on commit 4084373

Please sign in to comment.
Something went wrong with that request. Please try again.