aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/deprecation
diff options
context:
space:
mode:
authorBrandon Dunne <bdunne@redhat.com>2015-10-13 14:10:14 -0400
committerBrandon Dunne <bdunne@redhat.com>2015-10-14 07:49:39 -0400
commit6c98fbd9c3cc28ccbfc1b46a9ce3d58fdb19f3c8 (patch)
treec1cc494cb2b4a3c7fb62f275b84f8a6b0f96f468 /activesupport/test/deprecation
parent31af8c90b60dc475fd80d2919bfb874b4acc4507 (diff)
downloadrails-6c98fbd9c3cc28ccbfc1b46a9ce3d58fdb19f3c8.tar.gz
rails-6c98fbd9c3cc28ccbfc1b46a9ce3d58fdb19f3c8.tar.bz2
rails-6c98fbd9c3cc28ccbfc1b46a9ce3d58fdb19f3c8.zip
Fix bug where custom deprecators are not used.
Add tests for ActiveSupport::Deprecation.deprecate_methods Modify ActiveSupport::Testing::Deprecation to allow a custom deprecator Leverage ActiveSupport::Testing::Deprecation assert_deprecated Update documentation for ActiveSupport::Deprecation.deprecate_methods Use cases: Using the default deprecator => "removed from Rails X.Y" Passing a custom deprecator in the options hash => "removed from MyGem next-release" Deprecating methods directly from custom deprecator => "removed from MyGem next-release"
Diffstat (limited to 'activesupport/test/deprecation')
-rw-r--r--activesupport/test/deprecation/method_wrappers_test.rb34
1 files changed, 34 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