diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-08-18 13:43:07 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-09-01 09:57:13 +0200 |
commit | cacb44874fd5dad608268325b00b4c0058950420 (patch) | |
tree | bed8811a71e5ac4aa099672cedbb17e56bd7d4f3 /activesupport/test/core_ext | |
parent | 9a6e3ae76322e0a8108f9bcf0a8440769328b9d7 (diff) | |
download | rails-cacb44874fd5dad608268325b00b4c0058950420.tar.gz rails-cacb44874fd5dad608268325b00b4c0058950420.tar.bz2 rails-cacb44874fd5dad608268325b00b4c0058950420.zip |
delegate method should treat :prefix => false same as :prefix => nil
[#5375 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 5d9cdf22c2..75404ec0e1 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -47,6 +47,14 @@ Project = Struct.new(:description, :person) do delegate :to_f, :to => :description, :allow_nil => true end +Developer = Struct.new(:client) do + delegate :name, :to => :client, :prefix => nil +end + +Tester = Struct.new(:client) do + delegate :name, :to => :client, :prefix => false +end + class Name delegate :upcase, :to => :@full_name @@ -97,6 +105,11 @@ class ModuleTest < Test::Unit::TestCase assert_equal invoice.customer_city, "Chicago" end + def test_delegation_prefix_with_nil_or_false + assert_equal Developer.new(@david).name, "David" + assert_equal Tester.new(@david).name, "David" + end + def test_delegation_prefix_with_instance_variable assert_raise ArgumentError do Class.new do |