diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-05-24 19:18:48 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-05-24 19:18:48 -0300 |
commit | 3ac9956bfc8603cdd9999edeec15219dff02d8a2 (patch) | |
tree | df2f4886e84d246bdd701a06be0874ed4848c25d /activesupport/test | |
parent | 04a0e895bc7102cd32d627a2c0bc56d207e26f43 (diff) | |
download | rails-3ac9956bfc8603cdd9999edeec15219dff02d8a2.tar.gz rails-3ac9956bfc8603cdd9999edeec15219dff02d8a2.tar.bz2 rails-3ac9956bfc8603cdd9999edeec15219dff02d8a2.zip |
Don't delegate to private methods of the targer
And make sure that it doesn't even try to call the method in the target.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 0120aae492..75490bf4c9 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -40,6 +40,12 @@ class Someone < Struct.new(:name, :place) FAILED_DELEGATE_LINE_2 = __LINE__ + 1 delegate :bar, :to => :place, :allow_nil => true + + private + + def private_name + "Private" + end end Invoice = Struct.new(:client) do @@ -338,6 +344,14 @@ class ModuleTest < ActiveSupport::TestCase assert_equal "David", DecoratedReserved.new(@david).name end + def test_delegate_to_missing_does_not_delegate_to_private_methods + e = assert_raises(NoMethodError) do + DecoratedReserved.new(@david).private_name + end + + assert_match(/undefined method `private_name' for/, e.message) + end + def test_parent assert_equal Yz::Zy, Yz::Zy::Cd.parent assert_equal Yz, Yz::Zy.parent |