Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Deprecate AR::Base#attributes argument

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
commit 642da856d5dddbef4141f759e6e2bf57d5a3a3a8 1 parent 63edc02
@fcheung fcheung authored lifo committed
View
1  activerecord/lib/active_record/base.rb
@@ -2145,6 +2145,7 @@ def attributes(options = nil)
if options.nil?
attributes
else
+ ActiveSupport::Deprecation.warn "Passing options to Base#attributes is deprecated and will be removed in Rails 2.1. Please use Hash#slice or Hash#except instead"
if except = options[:except]
except = Array(except).collect { |attribute| attribute.to_s }
except.each { |attribute_name| attributes.delete(attribute_name) }
View
24 activerecord/test/base_test.rb
@@ -1706,20 +1706,24 @@ def test_to_xml_with_block
end
def test_except_attributes
- assert_equal(
- %w( author_name type id approved replies_count bonus_time written_on content author_email_address parent_id last_read),
- topics(:first).attributes(:except => :title).keys
- )
+ assert_deprecated do
+ assert_equal(
+ %w( author_name type id approved replies_count bonus_time written_on content author_email_address parent_id last_read),
+ topics(:first).attributes(:except => :title).keys
+ )
- assert_equal(
- %w( replies_count bonus_time written_on content author_email_address parent_id last_read),
- topics(:first).attributes(:except => [ :title, :id, :type, :approved, :author_name ]).keys
- )
+ assert_equal(
+ %w( replies_count bonus_time written_on content author_email_address parent_id last_read),
+ topics(:first).attributes(:except => [ :title, :id, :type, :approved, :author_name ]).keys
+ )
+ end
end
def test_include_attributes
- assert_equal(%w( title ), topics(:first).attributes(:only => :title).keys)
- assert_equal(%w( title author_name type id approved ), topics(:first).attributes(:only => [ :title, :id, :type, :approved, :author_name ]).keys)
+ assert_deprecated do
+ assert_equal(%w( title ), topics(:first).attributes(:only => :title).keys)
+ assert_equal(%w( title author_name type id approved ), topics(:first).attributes(:only => [ :title, :id, :type, :approved, :author_name ]).keys)
+ end
end
def test_type_name_with_module_should_handle_beginning
Please sign in to comment.
Something went wrong with that request. Please try again.