aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/attribute_methods_test.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-09-09 09:08:27 +0100
committerJon Leighton <j@jonathanleighton.com>2011-09-13 00:01:57 +0100
commit99bd6b53da9555450afb1e050324007868e0768c (patch)
treeb77bdc373a39b438613fda922057539029b882d6 /activemodel/test/cases/attribute_methods_test.rb
parent93d574c9627ade0b0bdf4ff05471dabe18cafedc (diff)
downloadrails-99bd6b53da9555450afb1e050324007868e0768c.tar.gz
rails-99bd6b53da9555450afb1e050324007868e0768c.tar.bz2
rails-99bd6b53da9555450afb1e050324007868e0768c.zip
Add deprecation for doing `attribute_method_suffix ''`
Diffstat (limited to 'activemodel/test/cases/attribute_methods_test.rb')
-rw-r--r--activemodel/test/cases/attribute_methods_test.rb17
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