mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
renames the :abort deprecation behaviour to :raise
That is a better name, thanks @jeremy.
This commit is contained in:
parent
4c1454db22
commit
c7ac0a5b28
3 changed files with 7 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
|||
* 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.
|
||||
|
|
|
@ -7,7 +7,7 @@ module ActiveSupport
|
|||
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 @@ module ActiveSupport
|
|||
#
|
||||
# Available behaviors:
|
||||
#
|
||||
# [+abort+] Raises <tt>ActiveSupport::DeprecationException</tt>.
|
||||
# [+raise+] Raise <tt>ActiveSupport::DeprecationException</tt>.
|
||||
# [+stderr+] Log all deprecation warnings to +$stderr+.
|
||||
# [+log+] Log all deprecation warnings to +Rails.logger+.
|
||||
# [+notify+] Use +ActiveSupport::Notifications+ to notify +deprecation.rails+.
|
||||
|
|
|
@ -98,8 +98,8 @@ class DeprecationTest < ActiveSupport::TestCase
|
|||
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 @@ class DeprecationTest < ActiveSupport::TestCase
|
|||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue