提交 2d6abcce 编写于 作者: J Jeremy Kemper

Merge pull request #8518 from rwz/inheritable-basic-object

Properly deprecate AS::BasicObject without breaking subclasses of it
require 'active_support/deprecation'
require 'active_support/proxy_object'
module ActiveSupport
# :nodoc:
# Deprecated in favor of ActiveSupport::ProxyObject
BasicObject = Deprecation::DeprecatedConstantProxy.new('ActiveSupport::BasicObject', 'ActiveSupport::ProxyObject')
class BasicObject < ProxyObject
def self.inherited(*)
::ActiveSupport::Deprecation.warn 'ActiveSupport::BasicObject is deprecated! Use ActiveSupport::ProxyObject instead.'
super
end
end
end
require 'abstract_unit'
require 'active_support/deprecation'
require 'active_support/basic_object'
class BasicObjectTest < ActiveSupport::TestCase
test 'BasicObject warns about deprecation when inherited from' do
warn = 'ActiveSupport::BasicObject is deprecated! Use ActiveSupport::ProxyObject instead.'
ActiveSupport::Deprecation.expects(:warn).with(warn).once
Class.new(ActiveSupport::BasicObject)
end
end
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册