mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-06 00:02:18 -04:00
Alphabetizing maps being encoded by key can cause problems because the server side Rack relies on the fact that that a new array item will start with a repeated key. For example, given this encoding: ``` items: [ { :type => 'sku', :parent => 'sku_94ZYSC0wppRTbk' }, { :type => 'discount', :amount => -10000, :currency => 'cad', :description => 'potato' } ], ``` We need to have `type` appear first so that an array boundary is recognized. So the encoded form should take: ``` items[][type]=sku&items[][parent]=...&items[][type]=discount&items[][amount]=... ``` But currently `type` gets sorted to the back, so we get something more like: ``` items[][parent]=...&items[][type]=...&items[][amount]=...&items[][currency]=...&items[][description]=...&items[][type]=potato ``` Which the server will receive as this: ``` items: [ { :type => 'sku', :parent => 'sku_94ZYSC0wppRTbk', :amount => -10000, :currency => 'cad', :description => 'potato' } { :type => 'discount' } ], ``` Here we remove the alphabetization to fix the problem and correct a bad test.