mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
DeprecatedInstanceVariable#inspect doesn't warn since test/unit, error logs, and others use it for diagnostics.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5763 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
a8b53f1dbb
commit
01452feff1
2 changed files with 12 additions and 1 deletions
|
@ -143,7 +143,8 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
# Stand-in for @request, @attributes, etc.
|
||||
# Stand-in for @request, @attributes, @params, etc which emits deprecation
|
||||
# warnings on any method call (except #inspect).
|
||||
class DeprecatedInstanceVariableProxy
|
||||
instance_methods.each { |m| undef_method m unless m =~ /^__/ }
|
||||
|
||||
|
@ -151,6 +152,12 @@ module ActiveSupport
|
|||
@instance, @method, @var = instance, method, var
|
||||
end
|
||||
|
||||
# Don't give a deprecation warning on inspect since test/unit and error
|
||||
# logs rely on it for diagnostics.
|
||||
def inspect
|
||||
target.inspect
|
||||
end
|
||||
|
||||
private
|
||||
def method_missing(called, *args, &block)
|
||||
warn caller, called, args
|
||||
|
|
|
@ -79,6 +79,10 @@ class DeprecationTest < Test::Unit::TestCase
|
|||
assert_deprecated('@request.to_s') { assert_equal @dtc.request.to_s, @dtc.old_request.to_s }
|
||||
end
|
||||
|
||||
def test_deprecated_instance_variable_proxy_shouldnt_warn_on_inspect
|
||||
assert_not_deprecated { assert_equal @dtc.request.inspect, @dtc.old_request.inspect }
|
||||
end
|
||||
|
||||
def test_assert_deprecation_without_match
|
||||
assert_deprecated do
|
||||
@dtc.partially
|
||||
|
|
Loading…
Reference in a new issue