From 359a0c9cdfdc90bccf200d699fb3037566ec4537 Mon Sep 17 00:00:00 2001 From: Remi Jannel <remi@stripe.com> Date: Wed, 16 Jan 2019 18:50:14 -0800 Subject: [PATCH] Move CheckoutSession to the Checkout namespace and rename to Session --- .travis.yml | 2 +- lib/stripe.rb | 2 +- lib/stripe/checkout/session.rb | 11 +++++++++ lib/stripe/checkout_session.rb | 9 ------- lib/stripe/util.rb | 2 +- test/stripe/checkout/session_test.rb | 35 ++++++++++++++++++++++++++++ test/stripe/checkout_session_test.rb | 33 -------------------------- test/test_helper.rb | 2 +- 8 files changed, 50 insertions(+), 46 deletions(-) create mode 100644 lib/stripe/checkout/session.rb delete mode 100644 lib/stripe/checkout_session.rb create mode 100644 test/stripe/checkout/session_test.rb delete mode 100644 test/stripe/checkout_session_test.rb diff --git a/.travis.yml b/.travis.yml index 1d7974984..49a263698 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ sudo: false env: global: # If changing this number, please also change it in `test/test_helper.rb`. - - STRIPE_MOCK_VERSION=0.40.1 + - STRIPE_MOCK_VERSION=0.42.0 cache: directories: diff --git a/lib/stripe.rb b/lib/stripe.rb index 6014347fa..a2463c6b6 100644 --- a/lib/stripe.rb +++ b/lib/stripe.rb @@ -49,7 +49,7 @@ require "stripe/bitcoin_transaction" require "stripe/card" require "stripe/charge" -require "stripe/checkout_session" +require "stripe/checkout/session" require "stripe/country_spec" require "stripe/coupon" require "stripe/customer" diff --git a/lib/stripe/checkout/session.rb b/lib/stripe/checkout/session.rb new file mode 100644 index 000000000..d94f2b16b --- /dev/null +++ b/lib/stripe/checkout/session.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Stripe + module Checkout + class Session < Stripe::APIResource + extend Stripe::APIOperations::Create + + OBJECT_NAME = "checkout.session".freeze + end + end +end diff --git a/lib/stripe/checkout_session.rb b/lib/stripe/checkout_session.rb deleted file mode 100644 index 0488b4fdb..000000000 --- a/lib/stripe/checkout_session.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -module Stripe - class CheckoutSession < APIResource - extend Stripe::APIOperations::Create - - OBJECT_NAME = "checkout_session".freeze - end -end diff --git a/lib/stripe/util.rb b/lib/stripe/util.rb index 45715c678..b1831dfe3 100644 --- a/lib/stripe/util.rb +++ b/lib/stripe/util.rb @@ -58,7 +58,7 @@ def self.object_classes # rubocop:disable Metrics/MethodLength BitcoinTransaction::OBJECT_NAME => BitcoinTransaction, Card::OBJECT_NAME => Card, Charge::OBJECT_NAME => Charge, - CheckoutSession::OBJECT_NAME => CheckoutSession, + Checkout::Session::OBJECT_NAME => Checkout::Session, CountrySpec::OBJECT_NAME => CountrySpec, Coupon::OBJECT_NAME => Coupon, Customer::OBJECT_NAME => Customer, diff --git a/test/stripe/checkout/session_test.rb b/test/stripe/checkout/session_test.rb new file mode 100644 index 000000000..72d75bc3f --- /dev/null +++ b/test/stripe/checkout/session_test.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require ::File.expand_path("../../../test_helper", __FILE__) + +module Stripe + module Checkout + class SessionTest < Test::Unit::TestCase + should "be creatable" do + session = Stripe::Checkout::Session.create( + allowed_source_types: ["card"], + cancel_url: "https://stripe.com/cancel", + client_reference_id: "1234", + line_items: [ + { + amount: 123, + currency: "usd", + description: "item 1", + images: [ + "https://stripe.com/img1", + ], + name: "name", + quantity: 2, + }, + ], + payment_intent_data: [ + receipt_email: "test@stripe.com", + ], + success_url: "https://stripe.com/success" + ) + assert_requested :post, "#{Stripe.api_base}/v1/checkout/sessions" + assert session.is_a?(Stripe::Checkout::Session) + end + end + end +end diff --git a/test/stripe/checkout_session_test.rb b/test/stripe/checkout_session_test.rb deleted file mode 100644 index 2c5fdeb80..000000000 --- a/test/stripe/checkout_session_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -require ::File.expand_path("../../test_helper", __FILE__) - -module Stripe - class CheckoutSessionTest < Test::Unit::TestCase - should "be creatable" do - session = Stripe::CheckoutSession.create( - allowed_source_types: ["card"], - cancel_url: "https://stripe.com/cancel", - client_reference_id: "1234", - line_items: [ - { - amount: 123, - currency: "usd", - description: "item 1", - images: [ - "https://stripe.com/img1", - ], - name: "name", - quantity: 2, - }, - ], - payment_intent_data: [ - receipt_email: "test@stripe.com", - ], - success_url: "https://stripe.com/success" - ) - assert_requested :post, "#{Stripe.api_base}/v1/checkout_sessions" - assert session.is_a?(Stripe::CheckoutSession) - end - end -end diff --git a/test/test_helper.rb b/test/test_helper.rb index c16f0511d..d077ddaef 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -17,7 +17,7 @@ require ::File.expand_path("../stripe_mock", __FILE__) # If changing this number, please also change it in `.travis.yml`. -MOCK_MINIMUM_VERSION = "0.40.1".freeze +MOCK_MINIMUM_VERSION = "0.42.0".freeze MOCK_PORT = Stripe::StripeMock.start # Disable all real network connections except those that are outgoing to