diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-11-29 20:10:33 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-11-29 20:13:37 +0000 |
commit | 8df787d42890017f182c1ac6cb082317c255a456 (patch) | |
tree | 55f662b09ad6d8e941999f3a6f98011044d413f0 /activemodel/test | |
parent | f3c84dc31692204aacac3c125dcfcc986fd961a0 (diff) | |
download | rails-8df787d42890017f182c1ac6cb082317c255a456.tar.gz rails-8df787d42890017f182c1ac6cb082317c255a456.tar.bz2 rails-8df787d42890017f182c1ac6cb082317c255a456.zip |
Deprecated `define_attr_method` in `ActiveModel::AttributeMethods`
This only existed to support methods like `set_table_name` in Active
Record, which are themselves being deprecated.
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/attribute_methods_test.rb | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb index 67471ed497..90f9b78334 100644 --- a/activemodel/test/cases/attribute_methods_test.rb +++ b/activemodel/test/cases/attribute_methods_test.rb @@ -134,20 +134,33 @@ class AttributeMethodsTest < ActiveModel::TestCase end test '#define_attr_method generates attribute method' do - ModelWithAttributes.define_attr_method(:bar, 'bar') + assert_deprecated do + ModelWithAttributes.define_attr_method(:bar, 'bar') + end assert_respond_to ModelWithAttributes, :bar - assert_equal "original bar", ModelWithAttributes.original_bar + + assert_deprecated do + assert_equal "original bar", ModelWithAttributes.original_bar + end + assert_equal "bar", ModelWithAttributes.bar - ModelWithAttributes.define_attr_method(:bar) + ActiveSupport::Deprecation.silence do + ModelWithAttributes.define_attr_method(:bar) + end assert !ModelWithAttributes.bar end test '#define_attr_method generates attribute method with invalid identifier characters' do - ModelWithWeirdNamesAttributes.define_attr_method(:'c?d', 'c?d') + ActiveSupport::Deprecation.silence do + ModelWithWeirdNamesAttributes.define_attr_method(:'c?d', 'c?d') + end assert_respond_to ModelWithWeirdNamesAttributes, :'c?d' - assert_equal "original c?d", ModelWithWeirdNamesAttributes.send('original_c?d') + + ActiveSupport::Deprecation.silence do + assert_equal "original c?d", ModelWithWeirdNamesAttributes.send('original_c?d') + end assert_equal "c?d", ModelWithWeirdNamesAttributes.send('c?d') end |