From 252e76f4fbdb476c4eebd83fc26629c216252287 Mon Sep 17 00:00:00 2001 From: Helen Ye Date: Wed, 6 Nov 2024 15:09:34 -0500 Subject: [PATCH 1/2] Fix retrieve stripe version --- lib/stripe/request_options.rb | 2 +- test/stripe/request_options_test.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/stripe/request_options.rb b/lib/stripe/request_options.rb index 56c29ec87..9006dcfe9 100644 --- a/lib/stripe/request_options.rb +++ b/lib/stripe/request_options.rb @@ -63,7 +63,7 @@ def self.combine_opts(object_opts, req_opts) idempotency_key: req_opts[:idempotency_key], stripe_account: req_opts[:stripe_account] || object_opts[:stripe_account], stripe_context: req_opts[:stripe_context] || object_opts[:stripe_context], - stripe_version: req_opts[:stripe_version] || object_opts[:api_version], + stripe_version: req_opts[:stripe_version] || object_opts[:stripe_version], } # Remove nil values from headers diff --git a/test/stripe/request_options_test.rb b/test/stripe/request_options_test.rb index af72abc29..d51c0848d 100644 --- a/test/stripe/request_options_test.rb +++ b/test/stripe/request_options_test.rb @@ -77,5 +77,17 @@ class RequestOptionsTest < Test::Unit::TestCase assert_equal({ "A-Header" => "header", "B-Header" => "header" }, request_opts[:headers]) end end + + context "combine_opts" do + should "correctly set stripe_version in retrieve" do + Stripe::Account.retrieve("acc_123", stripe_version: "2022-11-15") + + assert_requested( + :get, + "#{Stripe.api_base}/v1/accounts/acc_123", + headers: { "Stripe-Version" => "2022-11-15" } + ) + end + end end end From edc0ebd2af9c609121c461905bfbb4237d3f4cce Mon Sep 17 00:00:00 2001 From: Helen Ye Date: Wed, 6 Nov 2024 15:17:02 -0500 Subject: [PATCH 2/2] better test --- test/stripe/request_options_test.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/stripe/request_options_test.rb b/test/stripe/request_options_test.rb index d51c0848d..c9eefb8a5 100644 --- a/test/stripe/request_options_test.rb +++ b/test/stripe/request_options_test.rb @@ -79,14 +79,13 @@ class RequestOptionsTest < Test::Unit::TestCase end context "combine_opts" do - should "correctly set stripe_version in retrieve" do - Stripe::Account.retrieve("acc_123", stripe_version: "2022-11-15") - - assert_requested( - :get, - "#{Stripe.api_base}/v1/accounts/acc_123", - headers: { "Stripe-Version" => "2022-11-15" } - ) + should "correctly combine user specified options" do + object_opts = { api_key: "sk_123", stripe_version: "2022-11-15" } + request_opts = { api_key: "sk_456", stripe_account: "acct_123" } + combined = RequestOptions.combine_opts(object_opts, request_opts) + assert_equal(combined[:stripe_version], "2022-11-15") + assert_equal(combined[:api_key], "sk_456") + assert_equal(combined[:stripe_account], "acct_123") end end end