aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/attribute_methods_test.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-09-12 23:58:37 +0100
committerJon Leighton <j@jonathanleighton.com>2011-09-13 00:03:09 +0100
commit1a421ceccb25b15c87e97567fff573c941aa3ab3 (patch)
tree3355394c173c476e59b1c1004d9c4cc96af89d21 /activerecord/test/cases/attribute_methods_test.rb
parentc89e1c7bdefa2489f6ebd04862a426b7200bf494 (diff)
downloadrails-1a421ceccb25b15c87e97567fff573c941aa3ab3.tar.gz
rails-1a421ceccb25b15c87e97567fff573c941aa3ab3.tar.bz2
rails-1a421ceccb25b15c87e97567fff573c941aa3ab3.zip
Deprecate using method_missing for attributes that are columns.
This shouldn't ever happen unless people are doing something particularly weird, but adding a deprecation in case there are bugs not caught by our tests.
Diffstat (limited to 'activerecord/test/cases/attribute_methods_test.rb')
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 5ae3713e73..e324a252dd 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -675,6 +675,21 @@ class AttributeMethodsTest < ActiveRecord::TestCase
assert subklass.method_defined?(:id), "subklass is missing id method"
end
+ def test_dispatching_column_attributes_through_method_missing_deprecated
+ Topic.define_attribute_methods
+
+ topic = Topic.new(:id => 5)
+ topic.id = 5
+
+ topic.method(:id).owner.send(:remove_method, :id)
+
+ assert_deprecated do
+ assert_equal 5, topic.id
+ end
+ ensure
+ Topic.undefine_attribute_methods
+ end
+
private
def cached_columns
@cached_columns ||= (time_related_columns_on_topic + serialized_columns_on_topic).map(&:name)