diff options
author | Matthew Draper <matthew@trebex.net> | 2015-10-17 03:08:58 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2015-10-17 03:17:21 +1030 |
commit | 833aef438dab57c2c6523686fa9754faa023cd10 (patch) | |
tree | d399ae7ffb2276726b37131fe3059964f6fcebce /activesupport/test | |
parent | cd4575f98c11bfa698c0c7b6a3e1feae64006a76 (diff) | |
parent | 6c98fbd9c3cc28ccbfc1b46a9ce3d58fdb19f3c8 (diff) | |
download | rails-833aef438dab57c2c6523686fa9754faa023cd10.tar.gz rails-833aef438dab57c2c6523686fa9754faa023cd10.tar.bz2 rails-833aef438dab57c2c6523686fa9754faa023cd10.zip |
Merge pull request #21953 from bdunne/fix_dep_warn
Fix deprecation warning messages on deprecate_methods
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/deprecation/method_wrappers_test.rb | 34 | ||||
-rw-r--r-- | activesupport/test/deprecation_test.rb | 8 |
2 files changed, 42 insertions, 0 deletions
diff --git a/activesupport/test/deprecation/method_wrappers_test.rb b/activesupport/test/deprecation/method_wrappers_test.rb new file mode 100644 index 0000000000..9a4ca2b217 --- /dev/null +++ b/activesupport/test/deprecation/method_wrappers_test.rb @@ -0,0 +1,34 @@ +require 'abstract_unit' +require 'active_support/deprecation' + +class MethodWrappersTest < ActiveSupport::TestCase + def setup + @klass = Class.new do + def new_method; "abc" end + alias_method :old_method, :new_method + end + end + + def test_deprecate_methods_warning_default + warning = /old_method is deprecated and will be removed from Rails \d.\d \(use new_method instead\)/ + ActiveSupport::Deprecation.deprecate_methods(@klass, :old_method => :new_method) + + assert_deprecated(warning) { assert_equal "abc", @klass.new.old_method } + end + + def test_deprecate_methods_warning_with_optional_deprecator + warning = /old_method is deprecated and will be removed from MyGem next-release \(use new_method instead\)/ + deprecator = ActiveSupport::Deprecation.new("next-release", "MyGem") + ActiveSupport::Deprecation.deprecate_methods(@klass, :old_method => :new_method, :deprecator => deprecator) + + assert_deprecated(warning, deprecator) { assert_equal "abc", @klass.new.old_method } + end + + def test_deprecate_methods_warning_when_deprecated_with_custom_deprecator + warning = /old_method is deprecated and will be removed from MyGem next-release \(use new_method instead\)/ + deprecator = ActiveSupport::Deprecation.new("next-release", "MyGem") + deprecator.deprecate_methods(@klass, :old_method => :new_method) + + assert_deprecated(warning, deprecator) { assert_equal "abc", @klass.new.old_method } + end +end diff --git a/activesupport/test/deprecation_test.rb b/activesupport/test/deprecation_test.rb index 7e8844b301..cd02ad3f3f 100644 --- a/activesupport/test/deprecation_test.rb +++ b/activesupport/test/deprecation_test.rb @@ -163,6 +163,14 @@ class DeprecationTest < ActiveSupport::TestCase assert_not_deprecated { assert_equal Deprecatee::B::C.class, Deprecatee::A.class } end + def test_assert_deprecated_raises_when_method_not_deprecated + assert_raises(Minitest::Assertion) { assert_deprecated { @dtc.not } } + end + + def test_assert_not_deprecated + assert_raises(Minitest::Assertion) { assert_not_deprecated { @dtc.partially } } + end + def test_assert_deprecation_without_match assert_deprecated do @dtc.partially |