diff options
author | Li Ellis Gallardo <lellisga@gmail.com> | 2013-04-25 17:00:13 -0500 |
---|---|---|
committer | Li Ellis Gallardo <lellisga@gmail.com> | 2013-04-25 21:36:22 -0500 |
commit | ccbe02343934956d3bb11c7167e0493f9d8f08fd (patch) | |
tree | eaa4b31acfb5a306fdb1c5c680fec17f6a56078d /activesupport/test | |
parent | faa2c71deef44ded8ef73513e63229d057552540 (diff) | |
download | rails-ccbe02343934956d3bb11c7167e0493f9d8f08fd.tar.gz rails-ccbe02343934956d3bb11c7167e0493f9d8f08fd.tar.bz2 rails-ccbe02343934956d3bb11c7167e0493f9d8f08fd.zip |
Delegation method bug
Add documentation and test to delegation method that make sure we're
aware that when a delegated object is not nil or false and doesn't
respond to the method it will still raise a NoMethodError exception.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 82249ddd1b..9a8582075d 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -171,6 +171,11 @@ class ModuleTest < ActiveSupport::TestCase assert_nil rails.name end + def test_delegation_with_allow_nil_and_invalid_value + rails = Project.new("Rails", "David") + assert_raise(NoMethodError) { rails.name } + end + def test_delegation_with_allow_nil_and_nil_value_and_prefix Project.class_eval do delegate :name, :to => :person, :allow_nil => true, :prefix => true |