diff options
author | Matt Tanous <mtanous22@gmail.com> | 2018-07-25 17:04:34 -0400 |
---|---|---|
committer | Matt Tanous <mtanous22@gmail.com> | 2019-05-23 12:11:39 -0400 |
commit | f002be148e1377709ed28b8e80c5db76ee2fa410 (patch) | |
tree | eb368b86d475a4cd3449de50bc8af3d40e4b48fa /activesupport/test/core_ext | |
parent | eba859d867454cd441f29ff15d8dbf442e51919c (diff) | |
download | rails-f002be148e1377709ed28b8e80c5db76ee2fa410.tar.gz rails-f002be148e1377709ed28b8e80c5db76ee2fa410.tar.bz2 rails-f002be148e1377709ed28b8e80c5db76ee2fa410.zip |
Add :allow_nil option to delegate_missing_to; use in ActiveStorage
attachment
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 04692f1484..6e341480d1 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -92,6 +92,16 @@ DecoratedTester = Struct.new(:client) do delegate_missing_to :client end +class DecoratedMissingAllowNil + delegate_missing_to :case, allow_nil: true + + attr_reader :case + + def initialize(kase) + @case = kase + end +end + class DecoratedReserved delegate_missing_to :case @@ -382,6 +392,10 @@ class ModuleTest < ActiveSupport::TestCase assert_equal "name delegated to client, but client is nil", e.message end + def test_delegate_missing_to_returns_nil_if_allow_nil_and_nil_target + assert_nil DecoratedMissingAllowNil.new(nil).name + end + def test_delegate_missing_to_affects_respond_to assert_respond_to DecoratedTester.new(@david), :name assert_not_respond_to DecoratedTester.new(@david), :private_name |