Skip to content

Commit 75abad0

Browse files
author
Todd Mazierski
committed
Fix #930: only dup StackableValues.
1 parent e0b7357 commit 75abad0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/grape/util/stackable_values.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def freeze_value(key)
4545
def initialize_copy(other)
4646
super
4747
self.inherited_values = other.inherited_values
48-
self.new_values = other.new_values.deep_dup
48+
self.new_values = other.new_values.dup
4949
end
5050
end
5151
end

spec/grape/util/stackable_values_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ module Util
109109

110110
expect(grandchild.clone.to_hash).to eq(some_thing: [:foo, [:bar, :more], :grand_foo_bar], some_thing_more: [:foo_bar])
111111
end
112+
113+
context 'complex (i.e. not primitive) data types (ex. middleware, please see bug #930)' do
114+
let(:middleware) { double }
115+
116+
before { subject[:middleware] = middleware }
117+
118+
it 'copies values; does not duplicate them' do
119+
expect(obj_cloned[:middleware]).to eq [middleware]
120+
end
121+
end
112122
end
113123
end
114124
end

0 commit comments

Comments
 (0)