mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-08-24 00:00:51 -04:00
Order hack to make 1.8.7 tests happy
It turns out that the tests had been working ... but mostly by virtue of luck only. This should stabilize them more permanently.
This commit is contained in:
parent
7dabbd444a
commit
216218aeb0
@ -116,7 +116,10 @@ module Stripe
|
||||
|
||||
def self.flatten_params(params, parent_key=nil)
|
||||
result = []
|
||||
params.each do |key, value|
|
||||
|
||||
# do not sort the final output because arrays (and arrays of hashes
|
||||
# especially) can be order sensitive, but do sort incoming parameters
|
||||
params.sort_by { |(k, v)| k.to_s }.each do |key, value|
|
||||
calculated_key = parent_key ? "#{parent_key}[#{key}]" : "#{key}"
|
||||
if value.is_a?(Hash)
|
||||
result += flatten_params(value, calculated_key)
|
||||
|
@ -68,7 +68,7 @@ module Stripe
|
||||
|
||||
@mock.expects(:post).
|
||||
once.
|
||||
with('https://api.stripe.com/v1/accounts/acct_foo', nil, 'legal_entity[first_name]=Bob&legal_entity[address][line1]=2+Three+Four').
|
||||
with('https://api.stripe.com/v1/accounts/acct_foo', nil, 'legal_entity[address][line1]=2+Three+Four&legal_entity[first_name]=Bob').
|
||||
returns(make_response(resp))
|
||||
|
||||
a = Stripe::Account.retrieve('acct_foo')
|
||||
|
@ -60,7 +60,7 @@ module Stripe
|
||||
|
||||
if is_greater_than_ruby_1_9?
|
||||
check_metadata({:metadata => {:initial => 'true'}},
|
||||
'metadata[uuid]=6735&metadata[initial]=',
|
||||
'metadata[initial]=&metadata[uuid]=6735',
|
||||
update_actions)
|
||||
end
|
||||
end
|
||||
|
@ -33,8 +33,8 @@ module Stripe
|
||||
[:d, { :a => "a", :b => "b" }],
|
||||
[:e, [0, 1]],
|
||||
[:f, [
|
||||
{ :foo => "1", :bar => "2" },
|
||||
{ :foo => "3", :baz => "4" },
|
||||
{ :bar => "1", :foo => "2" },
|
||||
{ :baz => "3", :foo => "4" },
|
||||
]],
|
||||
]
|
||||
assert_equal([
|
||||
@ -49,10 +49,10 @@ module Stripe
|
||||
# *The key here is the order*. In order to be properly interpreted as
|
||||
# an array of hashes on the server, everything from a single hash must
|
||||
# come in at once. A duplicate key in an array triggers a new element.
|
||||
["f[][foo]", "1"],
|
||||
["f[][bar]", "2"],
|
||||
["f[][foo]", "3"],
|
||||
["f[][baz]", "4"],
|
||||
["f[][bar]", "1"],
|
||||
["f[][foo]", "2"],
|
||||
["f[][baz]", "3"],
|
||||
["f[][foo]", "4"],
|
||||
], Stripe::Util.flatten_params(params))
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user