diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-10 20:51:05 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-10 20:51:05 -0300 |
commit | 8c3a6f871eeaff1327c27b16c6d3955aaea4e555 (patch) | |
tree | 62be39b6f903bdb2be048bcbfe1a571d43c2d1dd /activesupport/test/core_ext/module_test.rb | |
parent | 10af9fae4a66f5f80c89ba75009cc7c7c9935a44 (diff) | |
parent | d15ddf04ec6fb0cd6d350ba57d9981ebee3eddd0 (diff) | |
download | rails-8c3a6f871eeaff1327c27b16c6d3955aaea4e555.tar.gz rails-8c3a6f871eeaff1327c27b16c6d3955aaea4e555.tar.bz2 rails-8c3a6f871eeaff1327c27b16c6d3955aaea4e555.zip |
Merge commit 'rails/master'
Diffstat (limited to 'activesupport/test/core_ext/module_test.rb')
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index f8387ae4ab..87f056ea85 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -32,7 +32,7 @@ end Somewhere = Struct.new(:street, :city) Someone = Struct.new(:name, :place) do - delegate :street, :city, :to => :place + delegate :street, :city, :to_f, :to => :place delegate :state, :to => :@place delegate :upcase, :to => "place.city" end @@ -44,6 +44,7 @@ end Project = Struct.new(:description, :person) do delegate :name, :to => :person, :allow_nil => true + delegate :to_f, :to => :description, :allow_nil => true end class Name @@ -145,6 +146,16 @@ class ModuleTest < Test::Unit::TestCase assert_raise(RuntimeError) { david.street } end + def test_delegation_to_method_that_exists_on_nil + nil_person = Someone.new(nil) + assert_equal 0.0, nil_person.to_f + end + + def test_delegation_to_method_that_exists_on_nil_when_allowing_nil + nil_project = Project.new(nil) + assert_equal 0.0, nil_project.to_f + end + def test_parent assert_equal Yz::Zy, Yz::Zy::Cd.parent assert_equal Yz, Yz::Zy.parent |