mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Deprecate Module#reachable?
method
This commit is contained in:
parent
f8e4c837c7
commit
9e4827a8ae
3 changed files with 23 additions and 10 deletions
|
@ -1,3 +1,7 @@
|
|||
* Deprecate `Module#reachable?` method.
|
||||
|
||||
*bogdanvlviv*
|
||||
|
||||
* Add `config/credentials.yml.enc` to store production app secrets.
|
||||
|
||||
Allows saving any authentication credentials for third party services
|
||||
|
|
|
@ -7,4 +7,5 @@ class Module
|
|||
def reachable? #:nodoc:
|
||||
!anonymous? && name.safe_constantize.equal?(self)
|
||||
end
|
||||
deprecate :reachable?
|
||||
end
|
||||
|
|
|
@ -5,13 +5,17 @@ require "active_support/core_ext/module/reachable"
|
|||
|
||||
class AnonymousTest < ActiveSupport::TestCase
|
||||
test "an anonymous class or module is not reachable" do
|
||||
assert !Module.new.reachable?
|
||||
assert !Class.new.reachable?
|
||||
assert_deprecated do
|
||||
assert !Module.new.reachable?
|
||||
assert !Class.new.reachable?
|
||||
end
|
||||
end
|
||||
|
||||
test "ordinary named classes or modules are reachable" do
|
||||
assert Kernel.reachable?
|
||||
assert Object.reachable?
|
||||
assert_deprecated do
|
||||
assert Kernel.reachable?
|
||||
assert Object.reachable?
|
||||
end
|
||||
end
|
||||
|
||||
test "a named class or module whose constant has gone is not reachable" do
|
||||
|
@ -21,8 +25,10 @@ class AnonymousTest < ActiveSupport::TestCase
|
|||
self.class.send(:remove_const, :C)
|
||||
self.class.send(:remove_const, :M)
|
||||
|
||||
assert !c.reachable?
|
||||
assert !m.reachable?
|
||||
assert_deprecated do
|
||||
assert !c.reachable?
|
||||
assert !m.reachable?
|
||||
end
|
||||
end
|
||||
|
||||
test "a named class or module whose constants store different objects are not reachable" do
|
||||
|
@ -35,9 +41,11 @@ class AnonymousTest < ActiveSupport::TestCase
|
|||
eval "class C; end"
|
||||
eval "module M; end"
|
||||
|
||||
assert C.reachable?
|
||||
assert M.reachable?
|
||||
assert !c.reachable?
|
||||
assert !m.reachable?
|
||||
assert_deprecated do
|
||||
assert C.reachable?
|
||||
assert M.reachable?
|
||||
assert !c.reachable?
|
||||
assert !m.reachable?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue