diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 4af6a6784542e..82d447b4c44f4 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,9 +1,9 @@ ## unreleased ## -* Adds a new deprecation behaviour that aborts the application. Throwing this +* Adds a new deprecation behaviour that raises an exception. Throwing this line into +config/environments/development.rb+ - ActiveSupport::Deprecation.behavior = :abort + ActiveSupport::Deprecation.behavior = :raise will cause the application to raise an +ActiveSupport::DeprecationException+ on deprecations. diff --git a/activesupport/lib/active_support/deprecation/behaviors.rb b/activesupport/lib/active_support/deprecation/behaviors.rb index dd31f7fff1e25..45df3accecd01 100644 --- a/activesupport/lib/active_support/deprecation/behaviors.rb +++ b/activesupport/lib/active_support/deprecation/behaviors.rb @@ -7,7 +7,7 @@ class DeprecationException < StandardError class Deprecation # Default warning behaviors per Rails.env. DEFAULT_BEHAVIORS = { - abort: ->(message, callstack) { + raise: ->(message, callstack) { e = DeprecationException.new(message) e.set_backtrace(callstack) raise e @@ -52,7 +52,7 @@ def behavior # # Available behaviors: # - # [+abort+] Raises ActiveSupport::DeprecationException. + # [+raise+] Raise ActiveSupport::DeprecationException. # [+stderr+] Log all deprecation warnings to +$stderr+. # [+log+] Log all deprecation warnings to +Rails.logger+. # [+notify+] Use +ActiveSupport::Notifications+ to notify +deprecation.rails+. diff --git a/activesupport/test/deprecation_test.rb b/activesupport/test/deprecation_test.rb index 641e5a210ce48..9674851b9dae4 100644 --- a/activesupport/test/deprecation_test.rb +++ b/activesupport/test/deprecation_test.rb @@ -98,8 +98,8 @@ def test_several_behaviors assert_match(/foo=nil/, @b) end - def test_abort_behaviour - ActiveSupport::Deprecation.behavior = :abort + def test_raise_behaviour + ActiveSupport::Deprecation.behavior = :raise message = 'Revise this deprecated stuff now!' callstack = %w(foo bar baz) @@ -110,7 +110,7 @@ def test_abort_behaviour assert_equal message, e.message assert_equal callstack, e.backtrace else - flunk 'the :abort deprecation behaviour should raise the expected exception' + flunk 'the :raise deprecation behaviour should raise the expected exception' end end