From abf490140e5ae17dc30f9c83638087fc22e10455 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 2 Jan 2020 15:00:00 -0800 Subject: [PATCH 1/2] Codegen for openapi ba4dcd0 --- lib/stripe/resources/source.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/stripe/resources/source.rb b/lib/stripe/resources/source.rb index 3c6091404..9d57aff6b 100644 --- a/lib/stripe/resources/source.rb +++ b/lib/stripe/resources/source.rb @@ -10,7 +10,8 @@ class Source < APIResource custom_method :verify, http_verb: :post - nested_resource_class_methods :source_transaction, operations: %i[list] + nested_resource_class_methods :source_transaction, + operations: %i[retrieve list] def verify(params = {}, opts = {}) request_stripe_object( From 52f491d40d97c2de2a6990968c99ad0c5214cef7 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 2 Jan 2020 15:06:29 -0800 Subject: [PATCH 2/2] Add tests --- test/stripe/source_test.rb | 28 ++++++++++++++++++++++++++ test/stripe/source_transaction_test.rb | 27 ------------------------- 2 files changed, 28 insertions(+), 27 deletions(-) delete mode 100644 test/stripe/source_transaction_test.rb diff --git a/test/stripe/source_test.rb b/test/stripe/source_test.rb index 5c2e55a1b..308142ea5 100644 --- a/test/stripe/source_test.rb +++ b/test/stripe/source_test.rb @@ -77,5 +77,33 @@ class SourceTest < Test::Unit::TestCase assert source.is_a?(Stripe::Source) end end + + context ".retrieve_source_transaction" do + should "retrieve a source transaction" do + Stripe::Source.retrieve_source_transaction( + "src_123", + "srctxn_123" + ) + assert_requested :get, "#{Stripe.api_base}/v1/sources/src_123/source_transactions/srctxn_123" + end + end + + context ".list_source_transactions" do + should "list source transactions" do + Stripe::Source.list_source_transactions( + "src_123" + ) + assert_requested :get, "#{Stripe.api_base}/v1/sources/src_123/source_transactions" + end + end + + context "#source_transactions" do + should "list source transactions" do + source = Stripe::Source.construct_from(id: "src_123", + object: "source") + source.source_transactions + assert_requested :get, "#{Stripe.api_base}/v1/sources/src_123/source_transactions" + end + end end end diff --git a/test/stripe/source_transaction_test.rb b/test/stripe/source_transaction_test.rb deleted file mode 100644 index cff504b89..000000000 --- a/test/stripe/source_transaction_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require ::File.expand_path("../test_helper", __dir__) - -module Stripe - class SourceTransactionTest < Test::Unit::TestCase - setup do - @source = Stripe::Source.retrieve("src_123") - end - - should "be listable (DEPRECATED)" do - transactions = @source.source_transactions - - assert_requested :get, "#{Stripe.api_base}/v1/sources/#{@source.id}/source_transactions" - assert transactions.data.is_a?(Array) - assert transactions.first.is_a?(Stripe::SourceTransaction) - end - - should "be listable" do - transactions = Stripe::Source.list_source_transactions(@source.id) - - assert_requested :get, "#{Stripe.api_base}/v1/sources/#{@source.id}/source_transactions" - assert transactions.data.is_a?(Array) - assert transactions.first.is_a?(Stripe::SourceTransaction) - end - end -end