diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-04-22 08:58:13 +0200 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-04-25 15:45:05 +0100 |
commit | 408437334bcb5df8d8daf7b60c13d496222954d2 (patch) | |
tree | 31057fef8f1ad814735d6220455cdb4db2f6daf4 /activerecord | |
parent | 2970e3f05454304b4fd0e58581b49665001cb68a (diff) | |
download | rails-408437334bcb5df8d8daf7b60c13d496222954d2.tar.gz rails-408437334bcb5df8d8daf7b60c13d496222954d2.tar.bz2 rails-408437334bcb5df8d8daf7b60c13d496222954d2.zip |
giving a hash to default scope should not be deprecated (well, not for this reason)
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/scoping/default.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/named_scope_test.rb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb index 45c34005c3..c887a106ef 100644 --- a/activerecord/lib/active_record/scoping/default.rb +++ b/activerecord/lib/active_record/scoping/default.rb @@ -90,7 +90,7 @@ module ActiveRecord 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 " \ diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index 0d3c0b20a4..2f4eb489ab 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -470,11 +470,11 @@ class NamedScopeTest < ActiveRecord::TestCase 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) |