diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 55d9fcb..082657a 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2145,6 +2145,7 @@ module ActiveRecord #:nodoc: 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) } diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index b9fad39..9371d94 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -1706,20 +1706,24 @@ class BasicsTest < Test::Unit::TestCase 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