Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return value of Customer#delete_discount #964

Merged
merged 1 commit into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/stripe/resources/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ class << self
alias detach_source delete_source
end

# Deletes a discount associated with the customer.
#
# Returns the deleted discount. The customer object is not updated,
# so you must call `refresh` on it to get a new version with the
# discount removed.
def delete_discount
resp, opts = execute_resource_request(:delete, resource_url + "/discount")
initialize_from(resp.data, opts, true)
Util.convert_to_stripe_object(resp.data, opts)
end
end
end
4 changes: 2 additions & 2 deletions test/stripe/customer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class CustomerTest < Test::Unit::TestCase
context "#delete_discount" do
should "delete a discount" do
customer = Stripe::Customer.retrieve("cus_123")
customer = customer.delete_discount
discount = customer.delete_discount
assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_123/discount"
assert customer.is_a?(Stripe::Customer)
assert discount.is_a?(Stripe::Discount)
end
end

Expand Down