From 1a787ebb7e4366147bf83ed7bb8b362164c841d5 Mon Sep 17 00:00:00 2001 From: Agis- Date: Thu, 18 Sep 2014 23:55:13 +0300 Subject: Delegation works with reserved words passed to `:to` Fixes #16956. --- activesupport/test/core_ext/module_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 380f5ad42b..3c49c4d14f 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -56,8 +56,14 @@ Developer = Struct.new(:client) do delegate :name, :to => :client, :prefix => nil end +Event = Struct.new(:case) do + delegate :foo, :to => :case +end + Tester = Struct.new(:client) do delegate :name, :to => :client, :prefix => false + + def foo; 1; end end Product = Struct.new(:name) do @@ -495,4 +501,9 @@ class MethodAliasingTest < ActiveSupport::TestCase assert_equal 'duck_with_orange', @instance.duck assert FooClassWithBarMethod.public_method_defined?(:duck) end + + def test_delegate_with_case + event = Event.new(Tester.new) + assert_equal 1, event.foo + end end -- cgit v1.2.3