Move tests for nested resources up to the parent class

This commit is contained in:
Remi Jannel 2019-04-12 19:23:52 -07:00
parent c3e65b2552
commit 5aa63d2cc6
12 changed files with 288 additions and 372 deletions

View File

@ -1,69 +0,0 @@
# frozen_string_literal: true
require ::File.expand_path("../../test_helper", __FILE__)
module Stripe
class AccountExternalAccountsOperationsTest < Test::Unit::TestCase
setup do
@account_id = "acct_123"
@external_account_id = "ba_123"
end
context "#create_external_account" do
should "create an external account" do
external_account = Stripe::Account.create_external_account(
@account_id,
external_account: "btok_123"
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/#{@account_id}/external_accounts"
assert external_account.is_a?(Stripe::BankAccount)
end
end
context "#retrieve_external_account" do
should "retrieve an external account" do
external_account = Stripe::Account.retrieve_external_account(
@account_id,
@external_account_id
)
assert_requested :get, "#{Stripe.api_base}/v1/accounts/#{@account_id}/external_accounts/#{@external_account_id}"
assert external_account.is_a?(Stripe::BankAccount)
end
end
context "#update_external_account" do
should "update an external account" do
external_account = Stripe::Account.update_external_account(
@account_id,
@external_account_id,
metadata: { foo: "bar" }
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/#{@account_id}/external_accounts/#{@external_account_id}"
assert external_account.is_a?(Stripe::BankAccount)
end
end
context "#delete_external_account" do
should "delete an external_account" do
external_account = Stripe::Account.delete_external_account(
@account_id,
@external_account_id
)
assert_requested :delete, "#{Stripe.api_base}/v1/accounts/#{@account_id}/external_accounts/#{@external_account_id}"
assert external_account.deleted
assert_equal @external_account_id, external_account.id
end
end
context "#list_external_accounts" do
should "list the account's external accounts" do
external_accounts = Stripe::Account.list_external_accounts(
@account_id
)
assert_requested :get, "#{Stripe.api_base}/v1/accounts/#{@account_id}/external_accounts"
assert external_accounts.is_a?(Stripe::ListObject)
assert external_accounts.data.is_a?(Array)
end
end
end
end

View File

@ -1,21 +0,0 @@
# frozen_string_literal: true
require ::File.expand_path("../../test_helper", __FILE__)
module Stripe
class AccountLoginLinksOperationsTest < Test::Unit::TestCase
setup do
@account_id = "acct_123"
end
context "#create_login_link" do
should "create a login link" do
login_link = Stripe::Account.create_login_link(
@account_id
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/#{@account_id}/login_links"
assert login_link.is_a?(Stripe::LoginLink)
end
end
end
end

View File

@ -1,70 +0,0 @@
# frozen_string_literal: true
require ::File.expand_path("../../test_helper", __FILE__)
module Stripe
class AccountPersonsOperationsTest < Test::Unit::TestCase
setup do
@account_id = "acct_123"
@person_id = "person_123"
end
context "#create_person" do
should "create a person" do
person = Stripe::Account.create_person(
@account_id,
first_name: "John",
last_name: "Doe"
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/#{@account_id}/persons"
assert person.is_a?(Stripe::Person)
end
end
context "#retrieve_person" do
should "retrieve a person" do
person = Stripe::Account.retrieve_person(
@account_id,
@person_id
)
assert_requested :get, "#{Stripe.api_base}/v1/accounts/#{@account_id}/persons/#{@person_id}"
assert person.is_a?(Stripe::Person)
end
end
context "#update_person" do
should "update a person" do
person = Stripe::Account.update_person(
@account_id,
@person_id,
first_name: "John"
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/#{@account_id}/persons/#{@person_id}"
assert person.is_a?(Stripe::Person)
end
end
context "#delete_person" do
should "delete an person" do
person = Stripe::Account.delete_person(
@account_id,
@person_id
)
assert_requested :delete, "#{Stripe.api_base}/v1/accounts/#{@account_id}/persons/#{@person_id}"
assert person.deleted
assert_equal @person_id, person.id
end
end
context "#list_persons" do
should "list the account's external accounts" do
persons = Stripe::Account.list_persons(
@account_id
)
assert_requested :get, "#{Stripe.api_base}/v1/accounts/#{@account_id}/persons"
assert persons.is_a?(Stripe::ListObject)
assert persons.data.is_a?(Array)
end
end
end
end

View File

@ -265,5 +265,130 @@ module Stripe
assert_equal(expected, obj.serialize_params)
end
end
context "#create_external_account" do
should "create an external account" do
external_account = Stripe::Account.create_external_account(
"acct_123",
external_account: "btok_123"
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_123/external_accounts"
assert external_account.is_a?(Stripe::BankAccount)
end
end
context "#retrieve_external_account" do
should "retrieve an external account" do
external_account = Stripe::Account.retrieve_external_account(
"acct_123",
"ba_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_123/external_accounts/ba_123"
assert external_account.is_a?(Stripe::BankAccount)
end
end
context "#update_external_account" do
should "update an external account" do
external_account = Stripe::Account.update_external_account(
"acct_123",
"ba_123",
metadata: { foo: "bar" }
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_123/external_accounts/ba_123"
assert external_account.is_a?(Stripe::BankAccount)
end
end
context "#delete_external_account" do
should "delete an external_account" do
external_account = Stripe::Account.delete_external_account(
"acct_123",
"ba_123"
)
assert_requested :delete, "#{Stripe.api_base}/v1/accounts/acct_123/external_accounts/ba_123"
assert external_account.deleted
assert_equal "ba_123", external_account.id
end
end
context "#list_external_accounts" do
should "list the account's external accounts" do
external_accounts = Stripe::Account.list_external_accounts(
"acct_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_123/external_accounts"
assert external_accounts.is_a?(Stripe::ListObject)
assert external_accounts.data.is_a?(Array)
end
end
context "#create_login_link" do
should "create a login link" do
login_link = Stripe::Account.create_login_link(
"acct_123"
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_123/login_links"
assert login_link.is_a?(Stripe::LoginLink)
end
end
context "#create_person" do
should "create a person" do
person = Stripe::Account.create_person(
"acct_123",
first_name: "John",
last_name: "Doe"
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_123/persons"
assert person.is_a?(Stripe::Person)
end
end
context "#retrieve_person" do
should "retrieve a person" do
person = Stripe::Account.retrieve_person(
"acct_123",
"person_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_123/persons/person_123"
assert person.is_a?(Stripe::Person)
end
end
context "#update_person" do
should "update a person" do
person = Stripe::Account.update_person(
"acct_123",
"person_123",
first_name: "John"
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_123/persons/person_123"
assert person.is_a?(Stripe::Person)
end
end
context "#delete_person" do
should "delete an person" do
person = Stripe::Account.delete_person(
"acct_123",
"person_123"
)
assert_requested :delete, "#{Stripe.api_base}/v1/accounts/acct_123/persons/person_123"
assert person.deleted
assert_equal "person_123", person.id
end
end
context "#list_persons" do
should "list the account's external accounts" do
persons = Stripe::Account.list_persons(
"acct_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_123/persons"
assert persons.is_a?(Stripe::ListObject)
assert persons.data.is_a?(Array)
end
end
end
end

View File

@ -1,56 +0,0 @@
# frozen_string_literal: true
require ::File.expand_path("../../test_helper", __FILE__)
module Stripe
class ApplicationFeeRefundsOperationsTest < Test::Unit::TestCase
setup do
@application_fee_id = "fee_123"
@refund_id = "fr_123"
end
context "#create_refund" do
should "create a refund" do
refund = Stripe::ApplicationFee.create_refund(
@application_fee_id
)
assert_requested :post, "#{Stripe.api_base}/v1/application_fees/#{@application_fee_id}/refunds"
assert refund.is_a?(Stripe::ApplicationFeeRefund)
end
end
context "#retrieve_refund" do
should "retrieve a refund" do
refund = Stripe::ApplicationFee.retrieve_refund(
@application_fee_id,
@refund_id
)
assert_requested :get, "#{Stripe.api_base}/v1/application_fees/#{@application_fee_id}/refunds/#{@refund_id}"
assert refund.is_a?(Stripe::ApplicationFeeRefund)
end
end
context "#update_refund" do
should "update a refund" do
refund = Stripe::ApplicationFee.update_refund(
@application_fee_id,
@refund_id,
metadata: { foo: "bar" }
)
assert_requested :post, "#{Stripe.api_base}/v1/application_fees/#{@application_fee_id}/refunds/#{@refund_id}"
assert refund.is_a?(Stripe::ApplicationFeeRefund)
end
end
context "#list_refunds" do
should "list the application fee's refuns" do
refunds = Stripe::ApplicationFee.list_refunds(
@application_fee_id
)
assert_requested :get, "#{Stripe.api_base}/v1/application_fees/#{@application_fee_id}/refunds"
assert refunds.is_a?(Stripe::ListObject)
assert refunds.data.is_a?(Array)
end
end
end
end

View File

@ -10,5 +10,49 @@ module Stripe
assert fees.data.is_a?(Array)
assert fees.data[0].is_a?(Stripe::ApplicationFee)
end
context "#create_refund" do
should "create a refund" do
refund = Stripe::ApplicationFee.create_refund(
"fee_123"
)
assert_requested :post, "#{Stripe.api_base}/v1/application_fees/fee_123/refunds"
assert refund.is_a?(Stripe::ApplicationFeeRefund)
end
end
context "#retrieve_refund" do
should "retrieve a refund" do
refund = Stripe::ApplicationFee.retrieve_refund(
"fee_123",
"fr_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/application_fees/fee_123/refunds/fr_123"
assert refund.is_a?(Stripe::ApplicationFeeRefund)
end
end
context "#update_refund" do
should "update a refund" do
refund = Stripe::ApplicationFee.update_refund(
"fee_123",
"fr_123",
metadata: { foo: "bar" }
)
assert_requested :post, "#{Stripe.api_base}/v1/application_fees/fee_123/refunds/fr_123"
assert refund.is_a?(Stripe::ApplicationFeeRefund)
end
end
context "#list_refunds" do
should "list the application fee's refuns" do
refunds = Stripe::ApplicationFee.list_refunds(
"fee_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/application_fees/fee_123/refunds"
assert refunds.is_a?(Stripe::ListObject)
assert refunds.data.is_a?(Array)
end
end
end
end

View File

@ -1,64 +0,0 @@
# frozen_string_literal: true
require ::File.expand_path("../../test_helper", __FILE__)
module Stripe
class CustomerSourcesOperationsTest < Test::Unit::TestCase
setup do
@customer_id = "cus_123"
@source_id = "ba_123"
end
context "#create_source" do
should "create a source" do
Stripe::Customer.create_source(
@customer_id,
source: "tok_123"
)
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources"
end
end
context "#retrieve_source" do
should "retrieve a source" do
Stripe::Customer.retrieve_source(
@customer_id,
@source_id
)
assert_requested :get, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
end
end
context "#update_source" do
should "update a source" do
Stripe::Customer.update_source(
@customer_id,
@source_id,
metadata: { foo: "bar" }
)
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
end
end
context "#delete_source" do
should "delete a source" do
Stripe::Customer.delete_source(
@customer_id,
@source_id
)
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
end
end
context "#list_sources" do
should "list the customer's sources" do
sources = Stripe::Customer.list_sources(
@customer_id
)
assert_requested :get, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources"
assert sources.is_a?(Stripe::ListObject)
assert sources.data.is_a?(Array)
end
end
end
end

View File

@ -113,6 +113,57 @@ module Stripe
assert discount.is_a?(Stripe::Discount)
end
end
context "#create_source" do
should "create a source" do
Stripe::Customer.create_source(
"cus_123",
source: "tok_123"
)
assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123/sources"
end
end
context "#retrieve_source" do
should "retrieve a source" do
Stripe::Customer.retrieve_source(
"cus_123",
"ba_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_123/sources/ba_123"
end
end
context "#update_source" do
should "update a source" do
Stripe::Customer.update_source(
"cus_123",
"ba_123",
metadata: { foo: "bar" }
)
assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123/sources/ba_123"
end
end
context "#delete_source" do
should "delete a source" do
Stripe::Customer.delete_source(
"cus_123",
"ba_123"
)
assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_123/sources/ba_123"
end
end
context "#list_sources" do
should "list the customer's sources" do
sources = Stripe::Customer.list_sources(
"cus_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_123/sources"
assert sources.is_a?(Stripe::ListObject)
assert sources.data.is_a?(Array)
end
end
context "source field" do
should "allow setting source with token" do

View File

@ -1,35 +0,0 @@
# frozen_string_literal: true
require ::File.expand_path("../../test_helper", __FILE__)
module Stripe
class SubscriptionScheduleRevisionsOperationsTest < Test::Unit::TestCase
setup do
@schedule_id = "sub_sched_123"
@revision_id = "sub_sched_rev_123"
end
context "#retrieve_revision" do
should "retrieve a subscription schedule revision" do
revision = Stripe::SubscriptionSchedule.retrieve_revision(
@schedule_id,
@revision_id
)
assert_requested :get, "#{Stripe.api_base}/v1/subscription_schedules/#{@schedule_id}/revisions/#{@revision_id}"
assert revision.is_a?(Stripe::SubscriptionScheduleRevision)
end
end
context "#list_revisions" do
should "list a subscription schedule's revisions" do
revisions = Stripe::SubscriptionSchedule.list_revisions(
@schedule_id
)
assert_requested :get, "#{Stripe.api_base}/v1/subscription_schedules/#{@schedule_id}/revisions"
assert revisions.is_a?(Stripe::ListObject)
assert revisions.data.is_a?(Array)
assert revisions.data[0].is_a?(Stripe::SubscriptionScheduleRevision)
end
end
end
end

View File

@ -89,5 +89,28 @@ module Stripe
assert revisions.data[0].is_a?(Stripe::SubscriptionScheduleRevision)
end
end
context "#retrieve_revision" do
should "retrieve a subscription schedule revision" do
revision = Stripe::SubscriptionSchedule.retrieve_revision(
"sub_sched_123",
"sub_sched_rev_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/subscription_schedules/sub_sched_123/revisions/sub_sched_rev_123"
assert revision.is_a?(Stripe::SubscriptionScheduleRevision)
end
end
context "#list_revisions" do
should "list a subscription schedule's revisions" do
revisions = Stripe::SubscriptionSchedule.list_revisions(
"sub_sched_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/subscription_schedules/sub_sched_123/revisions"
assert revisions.is_a?(Stripe::ListObject)
assert revisions.data.is_a?(Array)
assert revisions.data[0].is_a?(Stripe::SubscriptionScheduleRevision)
end
end
end
end

View File

@ -1,57 +0,0 @@
# frozen_string_literal: true
require ::File.expand_path("../../test_helper", __FILE__)
module Stripe
class TransferReversalsOperationsTest < Test::Unit::TestCase
setup do
@transfer_id = "tr_123"
@reversal_id = "trr_123"
end
context "#create_reversal" do
should "create a reversal" do
reversal = Stripe::Transfer.create_reversal(
@transfer_id,
amount: 100
)
assert_requested :post, "#{Stripe.api_base}/v1/transfers/#{@transfer_id}/reversals"
assert reversal.is_a?(Stripe::Reversal)
end
end
context "#retrieve_reversal" do
should "retrieve a reversal" do
reversal = Stripe::Transfer.retrieve_reversal(
@transfer_id,
@reversal_id
)
assert_requested :get, "#{Stripe.api_base}/v1/transfers/#{@transfer_id}/reversals/#{@reversal_id}"
assert reversal.is_a?(Stripe::Reversal)
end
end
context "#update_reversal" do
should "update a reversal" do
reversal = Stripe::Transfer.update_reversal(
@transfer_id,
@reversal_id,
metadata: { foo: "bar" }
)
assert_requested :post, "#{Stripe.api_base}/v1/transfers/#{@transfer_id}/reversals/#{@reversal_id}"
assert reversal.is_a?(Stripe::Reversal)
end
end
context "#list_reversals" do
should "list the transfer's reversals" do
reversals = Stripe::Transfer.list_reversals(
@transfer_id
)
assert_requested :get, "#{Stripe.api_base}/v1/transfers/#{@transfer_id}/reversals"
assert reversals.is_a?(Stripe::ListObject)
assert reversals.data.is_a?(Array)
end
end
end
end

View File

@ -39,5 +39,50 @@ module Stripe
assert_requested :post, "#{Stripe.api_base}/v1/transfers/tr_123"
assert transfer.is_a?(Stripe::Transfer)
end
context "#create_reversal" do
should "create a reversal" do
reversal = Stripe::Transfer.create_reversal(
"tr_123",
amount: 100
)
assert_requested :post, "#{Stripe.api_base}/v1/transfers/tr_123/reversals"
assert reversal.is_a?(Stripe::Reversal)
end
end
context "#retrieve_reversal" do
should "retrieve a reversal" do
reversal = Stripe::Transfer.retrieve_reversal(
"tr_123",
"trr_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/transfers/tr_123/reversals/trr_123"
assert reversal.is_a?(Stripe::Reversal)
end
end
context "#update_reversal" do
should "update a reversal" do
reversal = Stripe::Transfer.update_reversal(
"tr_123",
"trr_123",
metadata: { foo: "bar" }
)
assert_requested :post, "#{Stripe.api_base}/v1/transfers/tr_123/reversals/trr_123"
assert reversal.is_a?(Stripe::Reversal)
end
end
context "#list_reversals" do
should "list the transfer's reversals" do
reversals = Stripe::Transfer.list_reversals(
"tr_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/transfers/tr_123/reversals"
assert reversals.is_a?(Stripe::ListObject)
assert reversals.data.is_a?(Array)
end
end
end
end