mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-06-02 00:00:35 -04:00
Merge pull request #557 from stripe/slava-1156
Allows removing coupon via passing nil
This commit is contained in:
commit
5786abcb7a
@ -117,6 +117,11 @@ module Stripe
|
||||
|
||||
check_api_key!(api_key)
|
||||
|
||||
# there's no concept of a nil in form encoding, so convert any explicitly
|
||||
# provided nils to an empty string which the API will handle
|
||||
# appropriately
|
||||
params = params.merge(params) {|_, v| v.nil? ? '' : v}
|
||||
|
||||
params = Util.objects_to_ids(params)
|
||||
url = api_url(url, api_base)
|
||||
|
||||
|
@ -455,6 +455,20 @@ module Stripe
|
||||
client.execute_request(:post, '/v1/charges')
|
||||
end
|
||||
end
|
||||
|
||||
context "params serialization" do
|
||||
should 'convert nil params to empty string' do
|
||||
client = StripeClient.new
|
||||
client.execute_request(:get, '/v1/invoices/upcoming',
|
||||
params: {customer: API_FIXTURES[:customer][:id],
|
||||
subscription: API_FIXTURES[:subscription][:id],
|
||||
coupon: nil})
|
||||
assert_requested(:get, "#{Stripe.api_base}/v1/invoices/upcoming?",
|
||||
query: { customer: API_FIXTURES[:customer][:id],
|
||||
subscription: API_FIXTURES[:subscription][:id],
|
||||
coupon: '' })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "#request" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user