aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2019-07-22 12:19:00 -0400
committerGitHub <noreply@github.com>2019-07-22 12:19:00 -0400
commit2af445c3118f7f22b8c28bf2287b193a647bbb10 (patch)
tree6a2d3bce2facb164321fa71aca52007fdfe5e45f /activesupport/test
parent9ad806887096be1f60019a6b301a4c84aa1d8e65 (diff)
parent722c45f64110be876d83e7f9a22592aa954886c1 (diff)
downloadrails-2af445c3118f7f22b8c28bf2287b193a647bbb10.tar.gz
rails-2af445c3118f7f22b8c28bf2287b193a647bbb10.tar.bz2
rails-2af445c3118f7f22b8c28bf2287b193a647bbb10.zip
Merge pull request #36623 from alipman88/exclude_marshal_dump_from_delegate_missing_to
Exclude marshal_dump & _dump methods from being delegated via delegate_missing_to extension, fix #36522
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/module_test.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index ec9ecd06ee..dd36a9373a 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -111,6 +111,24 @@ class DecoratedReserved
end
end
+class Maze
+ attr_accessor :cavern, :passages
+end
+
+class Cavern
+ delegate_missing_to :target
+
+ attr_reader :maze
+
+ def initialize(maze)
+ @maze = maze
+ end
+
+ def target
+ @maze.passages = :twisty
+ end
+end
+
class Block
def hello?
true
@@ -411,6 +429,17 @@ class ModuleTest < ActiveSupport::TestCase
assert_respond_to DecoratedTester.new(@david), :extra_missing
end
+ def test_delegate_missing_to_does_not_interfere_with_marshallization
+ maze = Maze.new
+ maze.cavern = Cavern.new(maze)
+
+ array = [maze, nil]
+ serialized_array = Marshal.dump(array)
+ deserialized_array = Marshal.load(serialized_array)
+
+ assert_nil deserialized_array[1]
+ end
+
def test_delegate_with_case
event = Event.new(Tester.new)
assert_equal 1, event.foo