diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-03-22 19:26:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-22 19:26:44 -0400 |
commit | ccab1b2dbe8b4a21b99dedeab70da85a58e419af (patch) | |
tree | 9245050f580debbb1435c469abea5ab7318c0bba /activesupport/test | |
parent | 36334bf989a6a3e3b7254804d6c7f6227e2a98e9 (diff) | |
parent | d5ea4bde5913738447485a2652991d0e08c47eaf (diff) | |
download | rails-ccab1b2dbe8b4a21b99dedeab70da85a58e419af.tar.gz rails-ccab1b2dbe8b4a21b99dedeab70da85a58e419af.tar.bz2 rails-ccab1b2dbe8b4a21b99dedeab70da85a58e419af.zip |
Merge pull request #28528 from domcleal/parseerror-const-deprecation
Change AD::ParamsParser::ParseError deprecation so it can be rescued
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/deprecation_test.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/activesupport/test/deprecation_test.rb b/activesupport/test/deprecation_test.rb index 5f72fbf662..36d1ef0849 100644 --- a/activesupport/test/deprecation_test.rb +++ b/activesupport/test/deprecation_test.rb @@ -35,6 +35,18 @@ class Deprecatee A = ActiveSupport::Deprecation::DeprecatedConstantProxy.new("Deprecatee::A", "Deprecatee::B::C") end +class DeprecateeWithAccessor + include ActiveSupport::Deprecation::DeprecatedConstantAccessor + + module B + C = 1 + end + deprecate_constant "A", "DeprecateeWithAccessor::B::C" + + class NewException < StandardError; end + deprecate_constant "OldException", "DeprecateeWithAccessor::NewException" +end + class DeprecationTest < ActiveSupport::TestCase include ActiveSupport::Testing::Stream @@ -162,6 +174,17 @@ class DeprecationTest < ActiveSupport::TestCase assert_not_deprecated { assert_equal Deprecatee::B::C.class, Deprecatee::A.class } end + def test_deprecated_constant_accessor + assert_not_deprecated { DeprecateeWithAccessor::B::C } + assert_deprecated("DeprecateeWithAccessor::A") { assert_equal DeprecateeWithAccessor::B::C, DeprecateeWithAccessor::A } + end + + def test_deprecated_constant_accessor_exception + raise DeprecateeWithAccessor::NewException.new("Test") + rescue DeprecateeWithAccessor::OldException => e + assert_kind_of DeprecateeWithAccessor::NewException, e + end + def test_assert_deprecated_raises_when_method_not_deprecated assert_raises(Minitest::Assertion) { assert_deprecated { @dtc.not } } end |