diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-26 06:48:04 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-26 06:48:04 -0600 |
commit | 6616cb866eaf68e44dfd3324ffd543c9ce16869c (patch) | |
tree | 4ad237151b10a7efdeea8f7884c7940c306da5a8 /activesupport/test | |
parent | 09463183867f702d6ec66fce964ecb9f7ae0d98a (diff) | |
parent | 7189e5554e44928698b01c59e833edfbebf0c6be (diff) | |
download | rails-6616cb866eaf68e44dfd3324ffd543c9ce16869c.tar.gz rails-6616cb866eaf68e44dfd3324ffd543c9ce16869c.tar.bz2 rails-6616cb866eaf68e44dfd3324ffd543c9ce16869c.zip |
Merge pull request #22071 from yui-knk/redefine_method_keep_visibility
Make `Module#redefine_method` to keep method visibility
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/module/remove_method_test.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/module/remove_method_test.rb b/activesupport/test/core_ext/module/remove_method_test.rb index 77774afb0d..0d684dc70e 100644 --- a/activesupport/test/core_ext/module/remove_method_test.rb +++ b/activesupport/test/core_ext/module/remove_method_test.rb @@ -7,6 +7,16 @@ module RemoveMethodTests return 1 end + def do_something_protected + return 1 + end + protected :do_something_protected + + def do_something_private + return 1 + end + private :do_something_private + class << self def do_something_else return 2 @@ -34,8 +44,16 @@ class RemoveMethodTest < ActiveSupport::TestCase def test_redefine_method_in_an_object RemoveMethodTests::A.class_eval{ self.redefine_method(:do_something) { return 100 } + self.redefine_method(:do_something_protected) { return 100 } + self.redefine_method(:do_something_private) { return 100 } } assert_equal 100, RemoveMethodTests::A.new.do_something + assert_equal 100, RemoveMethodTests::A.new.send(:do_something_protected) + assert_equal 100, RemoveMethodTests::A.new.send(:do_something_private) + + assert RemoveMethodTests::A.public_method_defined? :do_something + assert RemoveMethodTests::A.protected_method_defined? :do_something_protected + assert RemoveMethodTests::A.private_method_defined? :do_something_private end -end
\ No newline at end of file +end |