diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-04-05 00:42:10 -0300 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2016-04-05 00:42:10 -0300 |
commit | 2a53011fd35b6c1d6b76993bf12352d7fe7d31c8 (patch) | |
tree | 05f286a497e8740be8592d029f25a3aed2803113 /activesupport | |
parent | 307eede533852406b887a30bbd1483da80b9dc71 (diff) | |
parent | 37a298b04350425b1055b7bead8560c3d5e7331d (diff) | |
download | rails-2a53011fd35b6c1d6b76993bf12352d7fe7d31c8.tar.gz rails-2a53011fd35b6c1d6b76993bf12352d7fe7d31c8.tar.bz2 rails-2a53011fd35b6c1d6b76993bf12352d7fe7d31c8.zip |
Merge pull request #24345 from mtsmfm/fix-marshal-with-autoloading-for-nested-class
Fix marshal with autoloading for nested class/module
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/marshal.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/marshal_test.rb | 21 |
2 files changed, 19 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/marshal.rb b/activesupport/lib/active_support/core_ext/marshal.rb index ca278cb2fa..5875ae5f71 100644 --- a/activesupport/lib/active_support/core_ext/marshal.rb +++ b/activesupport/lib/active_support/core_ext/marshal.rb @@ -3,7 +3,7 @@ module ActiveSupport def load(source) super(source) rescue ArgumentError, NameError => exc - if exc.message.match(%r|undefined class/module (.+)|) + if exc.message.match(%r|undefined class/module (.+?)(::)?\z|) # try loading the class/module loaded = $1.constantize diff --git a/activesupport/test/core_ext/marshal_test.rb b/activesupport/test/core_ext/marshal_test.rb index 07c0c0d8cb..380f64c6fd 100644 --- a/activesupport/test/core_ext/marshal_test.rb +++ b/activesupport/test/core_ext/marshal_test.rb @@ -29,7 +29,12 @@ class MarshalTest < ActiveSupport::TestCase ActiveSupport::Dependencies.clear with_autoloading_fixtures do - assert_kind_of EM, Marshal.load(dumped) + object = nil + assert_nothing_raised do + object = Marshal.load(dumped) + end + + assert_kind_of EM, object end end @@ -43,7 +48,12 @@ class MarshalTest < ActiveSupport::TestCase ActiveSupport::Dependencies.clear with_autoloading_fixtures do - assert_kind_of ClassFolder::ClassFolderSubclass, Marshal.load(dumped) + object = nil + assert_nothing_raised do + object = Marshal.load(dumped) + end + + assert_kind_of ClassFolder::ClassFolderSubclass, object end end @@ -128,7 +138,12 @@ class MarshalTest < ActiveSupport::TestCase ActiveSupport::Dependencies.clear with_autoloading_fixtures do - assert_kind_of EM, Marshal.load(f) + object = nil + assert_nothing_raised do + object = Marshal.load(f) + end + + assert_kind_of EM, object end end end |