mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-08-24 00:00:51 -04:00
Get requests with arrays of dictionaries to work
This commit is contained in:
parent
8c6dc1a838
commit
801dd99318
@ -110,7 +110,7 @@ module Stripe
|
||||
result = []
|
||||
value.each do |elem|
|
||||
if elem.is_a?(Hash)
|
||||
result += flatten_params(elem, calculated_key)
|
||||
result += flatten_params(elem, "#{calculated_key}[]")
|
||||
elsif elem.is_a?(Array)
|
||||
result += flatten_params_array(elem, calculated_key)
|
||||
else
|
||||
|
@ -95,5 +95,24 @@ module Stripe
|
||||
})
|
||||
assert c.paid
|
||||
end
|
||||
|
||||
should "properly handle an array or dictionaries" do
|
||||
@mock.expects(:post).with do |url, api_key, params|
|
||||
url == "#{Stripe.api_base}/v1/charges" && api_key.nil? && CGI.parse(params) == {
|
||||
'currency' => ['usd'], 'amount' => ['100'],
|
||||
'source' => ['btcrcv_test_receiver'],
|
||||
'level3[][red]' => ['firstred', 'another'],
|
||||
'level3[][one]' => ['fish'],
|
||||
}
|
||||
end.once.returns(make_response(make_charge))
|
||||
|
||||
c = Stripe::Charge.create({
|
||||
:amount => 100,
|
||||
:source => 'btcrcv_test_receiver',
|
||||
:currency => "usd",
|
||||
:level3 => [{:red => 'firstred'}, {:one => 'fish', :red => 'another'}]
|
||||
})
|
||||
assert c.paid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user