aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJake Bell <jake@theunraveler.com>2015-08-19 14:55:47 -0500
committerJake Bell <jake@theunraveler.com>2015-08-19 16:04:53 -0500
commit47ab9a04d3317d7d42c7b2e5709b8e861422ebc3 (patch)
tree1e315306f7d88f529a7d9d32691f19027631320b /activesupport/test
parentf454ad37ed46e14eb535eb3305d2c3183a5d52f7 (diff)
downloadrails-47ab9a04d3317d7d42c7b2e5709b8e861422ebc3.tar.gz
rails-47ab9a04d3317d7d42c7b2e5709b8e861422ebc3.tar.bz2
rails-47ab9a04d3317d7d42c7b2e5709b8e861422ebc3.zip
Fixing issue when delegating to methods named "block", "args", or "arg"
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/module_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index bdfbadcf1d..0ed66f8c37 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -83,6 +83,16 @@ Product = Struct.new(:name) do
end
end
+class Block
+ def hello?
+ true
+ end
+end
+
+HasBlock = Struct.new(:block) do
+ delegate :hello?, to: :block
+end
+
class ParameterSet
delegate :[], :[]=, :to => :@params
@@ -301,6 +311,11 @@ class ModuleTest < ActiveSupport::TestCase
assert_raise(NoMethodError) { product.type_name }
end
+ def test_delegation_with_method_arguments
+ has_block = HasBlock.new(Block.new)
+ assert has_block.hello?
+ end
+
def test_parent
assert_equal Yz::Zy, Yz::Zy::Cd.parent
assert_equal Yz, Yz::Zy.parent