Add a helper to add a beta version (#1343)

* Add a helper to add a beta header

* Typo
This commit is contained in:
helenye-stripe 2024-02-28 12:19:10 -08:00 committed by GitHub
parent d249b5f78b
commit 418d79de1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -121,6 +121,14 @@ module Stripe
}
end
def self.add_beta_version(beta_name, version)
if api_version.include?("; #{beta_name}=")
raise "Stripe version header #{api_version} already contains entry for beta #{beta_name}"
end
self.api_version = "#{api_version}; #{beta_name}=#{version}"
end
class Preview
def self._get_default_opts(opts)
{ api_mode: :preview }.merge(opts)

View File

@ -119,6 +119,18 @@ class StripeTest < Test::Unit::TestCase
assert_equal "2018-02-28", Stripe.api_version
end
should "allow beta versions to be added once only" do
Stripe.api_version = "2018-02-28"
Stripe.add_beta_version("my_beta", "v2")
assert_equal "2018-02-28; my_beta=v2", Stripe.api_version
err = assert_raises do
Stripe.add_beta_version("my_beta", "v1")
assert_equal(err, "Stripe version header 2018-02-28; my_beta=v2 already contains entry for beta my_beta")
end
end
should "allow connect_base to be configured" do
Stripe.connect_base = "https://other.stripe.com"
assert_equal "https://other.stripe.com", Stripe.connect_base