mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
Update normalize_opts to use dup instead of clone. (#985)
This commit is contained in:
parent
19da5510df
commit
90223fa06b
@ -208,7 +208,9 @@ module Stripe
|
||||
{ api_key: opts }
|
||||
when Hash
|
||||
check_api_key!(opts.fetch(:api_key)) if opts.key?(:api_key)
|
||||
opts.clone
|
||||
# Explicitly use dup here instead of clone to avoid preserving freeze
|
||||
# state on input params.
|
||||
opts.dup
|
||||
else
|
||||
raise TypeError, "normalize_opts expects a string or a hash"
|
||||
end
|
||||
|
@ -23,6 +23,14 @@ module Stripe
|
||||
assert_equal("bar", resource.foo)
|
||||
end
|
||||
|
||||
should "handle a frozen set of opts" do
|
||||
stub_request(:post, "#{Stripe.api_base}/v1/updateableresources/id")
|
||||
.with(body: { foo: "bar" })
|
||||
.to_return(body: JSON.generate(foo: "bar"))
|
||||
resource = UpdateableResource.update("id", { foo: "bar" }, {}.freeze)
|
||||
assert_equal("bar", resource.foo)
|
||||
end
|
||||
|
||||
should "error on protected fields" do
|
||||
e = assert_raises do
|
||||
UpdateableResource.update("id", protected: "bar")
|
||||
|
Loading…
x
Reference in New Issue
Block a user