aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorDaniel Schierbeck <daniel.schierbeck@gmail.com>2008-09-14 23:20:51 +0200
committerMichael Koziarski <michael@koziarski.com>2008-10-19 13:42:52 +0200
commit731c63f8ebc93e703b1a114d86f4f9f694ae48bf (patch)
tree53adee407b1874dc2a0d4eb48375df196406e993 /activesupport/test
parent6d1d48de6a16b0ff4e4533cccf00c0ec747feefb (diff)
downloadrails-731c63f8ebc93e703b1a114d86f4f9f694ae48bf.tar.gz
rails-731c63f8ebc93e703b1a114d86f4f9f694ae48bf.tar.bz2
rails-731c63f8ebc93e703b1a114d86f4f9f694ae48bf.zip
Added :prefix option to Module#delegate.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/module_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index ecdea38d44..071eefcb29 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -36,6 +36,10 @@ Someone = Struct.new(:name, :place) do
delegate :upcase, :to => "place.city"
end
+Invoice = Struct.new(:client) do
+ delegate :street, :city, :name, :to => :client, :prefix => true
+end
+
class Name
delegate :upcase, :to => :@full_name
@@ -85,6 +89,14 @@ class ModuleTest < Test::Unit::TestCase
assert_raises(ArgumentError) { eval($noplace) }
end
+ def test_delegation_prefix
+ david = Someone.new("David", Somewhere.new("Paulina", "Chicago"))
+ invoice = Invoice.new(david)
+ assert_equal invoice.client_name, "David"
+ assert_equal invoice.client_street, "Paulina"
+ assert_equal invoice.client_city, "Chicago"
+ end
+
def test_parent
assert_equal Yz::Zy, Yz::Zy::Cd.parent
assert_equal Yz, Yz::Zy.parent