AS::BasicObject can be inherited from

This commit is contained in:
Pavel Pravosud 2012-12-15 20:57:45 +07:00
parent 8f8397e0a4
commit bb1d3c1f8e
2 changed files with 19 additions and 2 deletions

View File

@ -1,7 +1,12 @@
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

View File

@ -0,0 +1,12 @@
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