diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-09-09 09:08:27 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-09-13 00:01:57 +0100 |
commit | 99bd6b53da9555450afb1e050324007868e0768c (patch) | |
tree | b77bdc373a39b438613fda922057539029b882d6 /activemodel/test/cases | |
parent | 93d574c9627ade0b0bdf4ff05471dabe18cafedc (diff) | |
download | rails-99bd6b53da9555450afb1e050324007868e0768c.tar.gz rails-99bd6b53da9555450afb1e050324007868e0768c.tar.bz2 rails-99bd6b53da9555450afb1e050324007868e0768c.zip |
Add deprecation for doing `attribute_method_suffix ''`
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/attribute_methods_test.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb index 95a7098ba4..61ff5fca7a 100644 --- a/activemodel/test/cases/attribute_methods_test.rb +++ b/activemodel/test/cases/attribute_methods_test.rb @@ -3,8 +3,6 @@ require 'cases/helper' class ModelWithAttributes include ActiveModel::AttributeMethods - attribute_method_suffix '' - class << self define_method(:bar) do 'original bar' @@ -39,8 +37,6 @@ end class ModelWithAttributesWithSpaces include ActiveModel::AttributeMethods - attribute_method_suffix '' - def attributes { :'foo bar' => 'value of foo bar'} end @@ -54,8 +50,6 @@ end class ModelWithWeirdNamesAttributes include ActiveModel::AttributeMethods - attribute_method_suffix '' - class << self define_method(:'c?d') do 'original c?d' @@ -146,4 +140,15 @@ class AttributeMethodsTest < ActiveModel::TestCase assert_equal 'bar', m.foo assert_equal 'bar', m.foo_test end + + test 'explicitly specifying an empty prefix/suffix is deprecated' do + klass = Class.new(ModelWithAttributes) + + assert_deprecated { klass.attribute_method_suffix '' } + assert_deprecated { klass.attribute_method_prefix '' } + + klass.define_attribute_methods([:foo]) + + assert_equal 'value of foo', klass.new.foo + end end |