未验证 提交 9e4827a8 编写于 作者: B bogdanvlviv

Deprecate `Module#reachable?` method

上级 f8e4c837
* Deprecate `Module#reachable?` method.
*bogdanvlviv*
* Add `config/credentials.yml.enc` to store production app secrets. * Add `config/credentials.yml.enc` to store production app secrets.
Allows saving any authentication credentials for third party services Allows saving any authentication credentials for third party services
......
...@@ -7,4 +7,5 @@ class Module ...@@ -7,4 +7,5 @@ class Module
def reachable? #:nodoc: def reachable? #:nodoc:
!anonymous? && name.safe_constantize.equal?(self) !anonymous? && name.safe_constantize.equal?(self)
end end
deprecate :reachable?
end end
...@@ -5,13 +5,17 @@ ...@@ -5,13 +5,17 @@
class AnonymousTest < ActiveSupport::TestCase class AnonymousTest < ActiveSupport::TestCase
test "an anonymous class or module is not reachable" do test "an anonymous class or module is not reachable" do
assert !Module.new.reachable? assert_deprecated do
assert !Class.new.reachable? assert !Module.new.reachable?
assert !Class.new.reachable?
end
end end
test "ordinary named classes or modules are reachable" do test "ordinary named classes or modules are reachable" do
assert Kernel.reachable? assert_deprecated do
assert Object.reachable? assert Kernel.reachable?
assert Object.reachable?
end
end end
test "a named class or module whose constant has gone is not reachable" do test "a named class or module whose constant has gone is not reachable" do
...@@ -21,8 +25,10 @@ class AnonymousTest < ActiveSupport::TestCase ...@@ -21,8 +25,10 @@ class AnonymousTest < ActiveSupport::TestCase
self.class.send(:remove_const, :C) self.class.send(:remove_const, :C)
self.class.send(:remove_const, :M) self.class.send(:remove_const, :M)
assert !c.reachable? assert_deprecated do
assert !m.reachable? assert !c.reachable?
assert !m.reachable?
end
end end
test "a named class or module whose constants store different objects are not reachable" do test "a named class or module whose constants store different objects are not reachable" do
...@@ -35,9 +41,11 @@ class AnonymousTest < ActiveSupport::TestCase ...@@ -35,9 +41,11 @@ class AnonymousTest < ActiveSupport::TestCase
eval "class C; end" eval "class C; end"
eval "module M; end" eval "module M; end"
assert C.reachable? assert_deprecated do
assert M.reachable? assert C.reachable?
assert !c.reachable? assert M.reachable?
assert !m.reachable? assert !c.reachable?
assert !m.reachable?
end
end end
end end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册