mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-08-24 00:00:51 -04:00
Remove sorting hack from parameter encoding
I added this for a regression suite so that 1.8.7 could pass its tests, but unfortunately this caused a regression in the way that parameters are encoded for arrays of hashes. This patch reverts the change and adds tests to detect a future regression. (And 1.8.7 is expected to fail on this initial commit.)
This commit is contained in:
parent
a41691d972
commit
395d16b8c1
@ -131,7 +131,7 @@ module Stripe
|
||||
# our 1.8.7 test suite where Hash key order is not preserved.
|
||||
#
|
||||
# https://www.igvita.com/2009/02/04/ruby-19-internals-ordered-hash/
|
||||
result.sort_by { |(k, _)| k }
|
||||
result
|
||||
end
|
||||
|
||||
def self.flatten_params_array(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[address][line1]=2+Three+Four&legal_entity[first_name]=Bob').
|
||||
with('https://api.stripe.com/v1/accounts/acct_foo', nil, 'legal_entity[first_name]=Bob&legal_entity[address][line1]=2+Three+Four').
|
||||
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[initial]=&metadata[uuid]=6735',
|
||||
'metadata[uuid]=6735&metadata[initial]=',
|
||||
update_actions)
|
||||
end
|
||||
end
|
||||
|
@ -31,15 +31,27 @@ module Stripe
|
||||
:c => "bar&baz",
|
||||
:d => { :a => "a", :b => "b" },
|
||||
:e => [0, 1],
|
||||
:f => [
|
||||
{ :foo => "1", :bar => "2" },
|
||||
{ :foo => "3", :baz => "4" },
|
||||
],
|
||||
}
|
||||
assert_equal([
|
||||
["a", 3],
|
||||
["b", "foo?"],
|
||||
["c", "bar&baz"],
|
||||
["d[a]", "a"],
|
||||
["d[b]", "b"],
|
||||
["e[]", 0],
|
||||
["e[]", 1],
|
||||
["a", 3],
|
||||
["b", "foo?"],
|
||||
["c", "bar&baz"],
|
||||
["d[a]", "a"],
|
||||
["d[b]", "b"],
|
||||
["e[]", 0],
|
||||
["e[]", 1],
|
||||
|
||||
# *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"],
|
||||
], Stripe::Util.flatten_params(params))
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user