stripe 1.58.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +4 -0
- data/.travis.yml +1 -2
- data/Gemfile +11 -12
- data/History.txt +8 -0
- data/README.md +44 -31
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/stripe.rb +4 -344
- data/lib/stripe/account.rb +4 -4
- data/lib/stripe/api_operations/create.rb +2 -2
- data/lib/stripe/api_operations/delete.rb +2 -2
- data/lib/stripe/api_operations/list.rb +2 -2
- data/lib/stripe/api_operations/request.rb +9 -3
- data/lib/stripe/api_operations/save.rb +4 -6
- data/lib/stripe/api_resource.rb +2 -2
- data/lib/stripe/bank_account.rb +2 -2
- data/lib/stripe/bitcoin_receiver.rb +1 -1
- data/lib/stripe/charge.rb +12 -12
- data/lib/stripe/customer.rb +6 -6
- data/lib/stripe/dispute.rb +2 -3
- data/lib/stripe/errors.rb +20 -10
- data/lib/stripe/invoice.rb +4 -4
- data/lib/stripe/list_object.rb +2 -2
- data/lib/stripe/order.rb +4 -4
- data/lib/stripe/reversal.rb +1 -1
- data/lib/stripe/source.rb +2 -2
- data/lib/stripe/stripe_client.rb +396 -0
- data/lib/stripe/stripe_response.rb +48 -0
- data/lib/stripe/transfer.rb +2 -2
- data/lib/stripe/util.rb +6 -6
- data/lib/stripe/version.rb +1 -1
- data/spec/fixtures.json +0 -0
- data/spec/fixtures.yaml +0 -0
- data/spec/spec.json +0 -0
- data/spec/spec.yaml +0 -0
- data/stripe.gemspec +1 -1
- data/test/api_fixtures.rb +29 -0
- data/test/api_stub_helpers.rb +125 -0
- data/test/stripe/account_test.rb +153 -247
- data/test/stripe/alipay_account_test.rb +10 -2
- data/test/stripe/api_operations_test.rb +3 -3
- data/test/stripe/api_resource_test.rb +139 -499
- data/test/stripe/apple_pay_domain_test.rb +22 -23
- data/test/stripe/application_fee_refund_test.rb +22 -31
- data/test/stripe/application_fee_test.rb +6 -17
- data/test/stripe/balance_test.rb +3 -3
- data/test/stripe/bank_account_test.rb +31 -11
- data/test/stripe/bitcoin_receiver_test.rb +51 -42
- data/test/stripe/bitcoin_transaction_test.rb +11 -19
- data/test/stripe/charge_test.rb +39 -126
- data/test/stripe/country_spec_test.rb +7 -30
- data/test/stripe/coupon_test.rb +33 -17
- data/test/stripe/customer_card_test.rb +25 -46
- data/test/stripe/customer_test.rb +86 -81
- data/test/stripe/dispute_test.rb +27 -38
- data/test/stripe/errors_test.rb +2 -2
- data/test/stripe/file_upload_test.rb +32 -24
- data/test/stripe/invoice_item_test.rb +46 -10
- data/test/stripe/invoice_test.rb +48 -48
- data/test/stripe/list_object_test.rb +22 -31
- data/test/stripe/order_return_test.rb +11 -15
- data/test/stripe/order_test.rb +38 -51
- data/test/stripe/plan_test.rb +39 -18
- data/test/stripe/product_test.rb +29 -33
- data/test/stripe/recipient_card_test.rb +23 -40
- data/test/stripe/recipient_test.rb +39 -10
- data/test/stripe/refund_test.rb +20 -45
- data/test/stripe/reversal_test.rb +27 -31
- data/test/stripe/sku_test.rb +36 -19
- data/test/stripe/source_test.rb +26 -66
- data/test/stripe/stripe_client_test.rb +428 -0
- data/test/stripe/stripe_object_test.rb +6 -2
- data/test/stripe/stripe_response_test.rb +46 -0
- data/test/stripe/subscription_item_test.rb +37 -59
- data/test/stripe/subscription_test.rb +40 -176
- data/test/stripe/three_d_secure_test.rb +13 -12
- data/test/stripe/transfer_test.rb +36 -19
- data/test/stripe_test.rb +3 -36
- data/test/test_data.rb +5 -931
- data/test/test_helper.rb +21 -25
- metadata +22 -17
- data/test/stripe/charge_refund_test.rb +0 -67
- data/test/stripe/metadata_test.rb +0 -129
data/test/stripe/plan_test.rb
CHANGED
@@ -2,30 +2,51 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class PlanTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:plan)
|
6
|
+
|
7
|
+
should "be listable" do
|
7
8
|
plans = Stripe::Plan.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/plans"
|
8
10
|
assert plans.data.kind_of?(Array)
|
9
|
-
plans.
|
10
|
-
|
11
|
-
|
11
|
+
assert plans.data[0].kind_of?(Stripe::Plan)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
plan = Stripe::Plan.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/plans/#{FIXTURE[:id]}"
|
17
|
+
assert plan.kind_of?(Stripe::Plan)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be creatable" do
|
21
|
+
plan = Stripe::Plan.create(
|
22
|
+
amount: 5000,
|
23
|
+
interval: "month",
|
24
|
+
name: "Sapphire elite",
|
25
|
+
currency: "usd",
|
26
|
+
id: "sapphire-elite"
|
27
|
+
)
|
28
|
+
assert_requested :post, "#{Stripe.api_base}/v1/plans"
|
29
|
+
assert plan.kind_of?(Stripe::Plan)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "be saveable" do
|
33
|
+
plan = Stripe::Plan.retrieve(FIXTURE[:id])
|
34
|
+
plan.metadata['key'] = 'value'
|
35
|
+
plan.save
|
36
|
+
assert_requested :post, "#{Stripe.api_base}/v1/plans/#{FIXTURE[:id]}"
|
12
37
|
end
|
13
38
|
|
14
|
-
should "
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
p.refresh
|
19
|
-
p.metadata['foo'] = 'bar'
|
20
|
-
p.save
|
39
|
+
should "be updateable" do
|
40
|
+
plan = Stripe::Plan.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
41
|
+
assert_requested :post, "#{Stripe.api_base}/v1/plans/#{FIXTURE[:id]}"
|
42
|
+
assert plan.kind_of?(Stripe::Plan)
|
21
43
|
end
|
22
44
|
|
23
|
-
should "
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
assert_equal('bar', p.metadata['foo'])
|
45
|
+
should "be deletable" do
|
46
|
+
plan = Stripe::Plan.retrieve(FIXTURE[:id])
|
47
|
+
plan = plan.delete
|
48
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/plans/#{FIXTURE[:id]}"
|
49
|
+
assert plan.kind_of?(Stripe::Plan)
|
29
50
|
end
|
30
51
|
end
|
31
52
|
end
|
data/test/stripe/product_test.rb
CHANGED
@@ -2,50 +2,46 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ProductTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:product)
|
6
|
+
|
7
|
+
should "be listable" do
|
7
8
|
products = Stripe::Product.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/products"
|
8
10
|
assert products.data.kind_of?(Array)
|
9
|
-
products.
|
10
|
-
assert product.kind_of?(Stripe::Product)
|
11
|
-
end
|
11
|
+
assert products.data[0].kind_of?(Stripe::Product)
|
12
12
|
end
|
13
13
|
|
14
|
-
should "
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
p = Stripe::Product.retrieve("test_product")
|
20
|
-
p.delete
|
21
|
-
assert p.deleted
|
14
|
+
should "be retrievable" do
|
15
|
+
product = Stripe::Product.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/products/#{FIXTURE[:id]}"
|
17
|
+
assert product.kind_of?(Stripe::Product)
|
22
18
|
end
|
23
19
|
|
24
|
-
should "
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
p.description = "New product description"
|
30
|
-
p.save
|
20
|
+
should "be creatable" do
|
21
|
+
_ = Stripe::Product.create(
|
22
|
+
name: "My Product"
|
23
|
+
)
|
24
|
+
assert_requested :post, "#{Stripe.api_base}/v1/products"
|
31
25
|
end
|
32
26
|
|
33
|
-
should "
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
assert_equal('update', p.description)
|
27
|
+
should "be saveable" do
|
28
|
+
product = Stripe::Product.retrieve(FIXTURE[:id])
|
29
|
+
product.metadata['key'] = 'value'
|
30
|
+
product.save
|
31
|
+
assert_requested :post, "#{Stripe.api_base}/v1/products/#{FIXTURE[:id]}"
|
39
32
|
end
|
40
33
|
|
41
|
-
should "
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
p.refresh
|
46
|
-
p.metadata['key'] = 'value'
|
47
|
-
p.save
|
34
|
+
should "be updateable" do
|
35
|
+
product = Stripe::Product.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
36
|
+
assert_requested :post, "#{Stripe.api_base}/v1/products/#{FIXTURE[:id]}"
|
37
|
+
assert product.kind_of?(Stripe::Product)
|
48
38
|
end
|
49
39
|
|
40
|
+
should "be deletable" do
|
41
|
+
product = Stripe::Product.retrieve(FIXTURE[:id])
|
42
|
+
product = product.delete
|
43
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/products/#{FIXTURE[:id]}"
|
44
|
+
assert product.kind_of?(Stripe::Product)
|
45
|
+
end
|
50
46
|
end
|
51
47
|
end
|
@@ -2,56 +2,39 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class RecipientCardTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:source)
|
6
6
|
|
7
|
-
|
8
|
-
@
|
9
|
-
|
7
|
+
setup do
|
8
|
+
@recipient =
|
9
|
+
Stripe::Recipient.retrieve(API_FIXTURES.fetch(:transfer_recipient)[:id])
|
10
10
|
end
|
11
11
|
|
12
|
-
should "
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
assert cards.kind_of? Array
|
17
|
-
assert cards[0].kind_of? Stripe::Card
|
12
|
+
should "be listable" do
|
13
|
+
cards = @recipient.cards.list
|
14
|
+
assert cards.data.kind_of?(Array)
|
15
|
+
assert cards.data[0].kind_of?(Stripe::Token)
|
18
16
|
end
|
19
17
|
|
20
|
-
should "
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
)
|
26
|
-
card = c.cards.retrieve('card')
|
27
|
-
assert_equal RECIPIENT_CARD_URL, card.resource_url
|
18
|
+
should "be creatable" do
|
19
|
+
card = @recipient.cards.create(
|
20
|
+
card: API_FIXTURES.fetch(:token)[:id]
|
21
|
+
)
|
22
|
+
assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{@recipient.id}/cards"
|
23
|
+
assert card.kind_of?(Stripe::Token)
|
28
24
|
end
|
29
25
|
|
30
|
-
should "
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
card
|
35
|
-
card.delete
|
36
|
-
assert card.deleted
|
26
|
+
should "be deletable" do
|
27
|
+
card = Stripe::Card.construct_from(FIXTURE.merge(recipient: @recipient.id))
|
28
|
+
card = card.delete
|
29
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/recipients/#{@recipient.id}/cards/#{FIXTURE[:id]}"
|
30
|
+
assert card.kind_of?(Stripe::Card)
|
37
31
|
end
|
38
32
|
|
39
|
-
should "
|
40
|
-
|
41
|
-
|
42
|
-
@mock.expects(:post).once.returns(make_response(make_card(:exp_year => "2100")))
|
43
|
-
card = c.cards.retrieve('card')
|
44
|
-
assert_equal "2000", card.exp_year
|
45
|
-
card.exp_year = "2100"
|
33
|
+
should "be saveable" do
|
34
|
+
card = Stripe::Card.construct_from(FIXTURE.merge(recipient: @recipient.id))
|
35
|
+
card.metadata['key'] = 'value'
|
46
36
|
card.save
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
should "create should return a new recipient card" do
|
51
|
-
c = recipient
|
52
|
-
@mock.expects(:post).once.returns(make_response(make_card(:id => "test_card")))
|
53
|
-
card = c.cards.create(:card => "tok_41YJ05ijAaWaFS")
|
54
|
-
assert_equal "test_card", card.id
|
37
|
+
assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{@recipient.id}/cards/#{FIXTURE[:id]}"
|
55
38
|
end
|
56
39
|
end
|
57
40
|
end
|
@@ -2,19 +2,48 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class RecipientTest < Test::Unit::TestCase
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:transfer_recipient)
|
5
6
|
|
6
|
-
should "
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
should "be listable" do
|
8
|
+
recipients = Stripe::Recipient.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/recipients"
|
10
|
+
assert recipients.data.kind_of?(Array)
|
11
|
+
assert recipients.data[0].kind_of?(Stripe::Recipient)
|
10
12
|
end
|
11
13
|
|
12
|
-
should "
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
should "be retrievable" do
|
15
|
+
recipient = Stripe::Recipient.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/recipients/#{FIXTURE[:id]}"
|
17
|
+
assert recipient.kind_of?(Stripe::Recipient)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be creatable" do
|
21
|
+
recipient = Stripe::Recipient.create(
|
22
|
+
name: "Noah Jackson",
|
23
|
+
type: "individual"
|
24
|
+
)
|
25
|
+
assert_requested :post, "#{Stripe.api_base}/v1/recipients"
|
26
|
+
assert recipient.kind_of?(Stripe::Recipient)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "be saveable" do
|
30
|
+
recipient = Stripe::Recipient.retrieve(FIXTURE[:id])
|
31
|
+
recipient.metadata['key'] = 'value'
|
32
|
+
recipient.save
|
33
|
+
assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{FIXTURE[:id]}"
|
34
|
+
end
|
35
|
+
|
36
|
+
should "be updateable" do
|
37
|
+
recipient = Stripe::Recipient.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
38
|
+
assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{FIXTURE[:id]}"
|
39
|
+
assert recipient.kind_of?(Stripe::Recipient)
|
40
|
+
end
|
41
|
+
|
42
|
+
should "be deletable" do
|
43
|
+
recipient = Stripe::Recipient.retrieve(FIXTURE[:id])
|
44
|
+
recipient = recipient.delete
|
45
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/recipients/#{FIXTURE[:id]}"
|
46
|
+
assert recipient.kind_of?(Stripe::Recipient)
|
18
47
|
end
|
19
48
|
end
|
20
49
|
end
|
data/test/stripe/refund_test.rb
CHANGED
@@ -2,63 +2,38 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class RefundTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).
|
7
|
-
with("#{Stripe.api_base}/v1/refunds", nil, nil).
|
8
|
-
once.returns(make_response(make_refund_array))
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:refund)
|
9
6
|
|
7
|
+
should "be listable" do
|
10
8
|
refunds = Stripe::Refund.list
|
11
|
-
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/refunds"
|
10
|
+
assert refunds.data.kind_of?(Array)
|
12
11
|
assert refunds.first.kind_of?(Stripe::Refund)
|
13
12
|
end
|
14
13
|
|
15
|
-
should "
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
make_response(make_refund(:id => 'refreshed_refund')))
|
20
|
-
|
21
|
-
refund = Stripe::Refund.retrieve('test_refund')
|
22
|
-
refund.refresh
|
23
|
-
|
24
|
-
assert_equal 'refreshed_refund', refund.id
|
14
|
+
should "be retrievable" do
|
15
|
+
refund = Stripe::Refund.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/refunds/#{FIXTURE[:id]}"
|
17
|
+
assert refund.kind_of?(Stripe::Refund)
|
25
18
|
end
|
26
19
|
|
27
|
-
should "
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
@mock.expects(:post).
|
33
|
-
with("#{Stripe.api_base}/v1/refunds/save_refund", nil, 'metadata[key]=value').
|
34
|
-
once.returns(make_response(make_refund(:metadata => {'key' => 'value'})))
|
35
|
-
|
36
|
-
refund = Stripe::Refund.retrieve('get_refund')
|
37
|
-
|
38
|
-
assert_equal nil, refund.metadata['key']
|
20
|
+
should "be creatable" do
|
21
|
+
refund = Stripe::Refund.create(:charge => API_FIXTURES[:charge][:id])
|
22
|
+
assert_requested :post, "#{Stripe.api_base}/v1/refunds"
|
23
|
+
assert refund.kind_of?(Stripe::Refund)
|
24
|
+
end
|
39
25
|
|
26
|
+
should "be saveable" do
|
27
|
+
refund = Stripe::Refund.retrieve(FIXTURE[:id])
|
40
28
|
refund.metadata['key'] = 'value'
|
41
29
|
refund.save
|
42
|
-
|
43
|
-
assert_equal 'value', refund.metadata['key']
|
44
|
-
end
|
45
|
-
|
46
|
-
should "refunds should be updateable" do
|
47
|
-
@mock.expects(:post).
|
48
|
-
with("#{Stripe.api_base}/v1/refunds/update_refund", nil, 'metadata[key]=value').
|
49
|
-
once.returns(make_response(make_refund(:metadata => {'key' => 'value'})))
|
50
|
-
|
51
|
-
refund = Stripe::Refund.update('update_refund', metadata: {key: 'value'})
|
52
|
-
assert_equal 'value', refund.metadata['key']
|
30
|
+
assert_requested :post, "#{Stripe.api_base}/v1/refunds/#{FIXTURE[:id]}"
|
53
31
|
end
|
54
32
|
|
55
|
-
should "
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
refund = Stripe::Refund.create(:charge => 'test_charge')
|
61
|
-
assert_equal 'test_new_refund', refund.id
|
33
|
+
should "be updateable" do
|
34
|
+
refund = Stripe::Refund.update(FIXTURE[:id], metadata: { key: 'value' })
|
35
|
+
assert_requested :post, "#{Stripe.api_base}/v1/refunds/#{FIXTURE[:id]}"
|
36
|
+
assert refund.kind_of?(Stripe::Refund)
|
62
37
|
end
|
63
38
|
end
|
64
39
|
end
|
@@ -2,46 +2,42 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ReversalTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_transfer))
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:transfer_reversal)
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
assert transfer.reversals.first.kind_of?(Stripe::Reversal)
|
7
|
+
setup do
|
8
|
+
@transfer = Stripe::Transfer.retrieve(API_FIXTURES.fetch(:transfer)[:id])
|
11
9
|
end
|
12
10
|
|
13
|
-
should "
|
14
|
-
@
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
assert_equal 'refreshed_reversal', reversal.id
|
11
|
+
should "be listable" do
|
12
|
+
reversals = @transfer.reversals.list
|
13
|
+
assert_requested :get,
|
14
|
+
"#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals"
|
15
|
+
assert reversals.data.kind_of?(Array)
|
16
|
+
assert reversals.data[0].kind_of?(Stripe::Reversal)
|
21
17
|
end
|
22
18
|
|
23
|
-
should "
|
24
|
-
@
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
should "be retrievable" do
|
20
|
+
reversal = @transfer.reversals.retrieve(FIXTURE[:id])
|
21
|
+
assert_requested :get,
|
22
|
+
"#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals/#{FIXTURE[:id]}"
|
23
|
+
assert reversal.kind_of?(Stripe::Reversal)
|
24
|
+
end
|
29
25
|
|
30
|
-
|
26
|
+
should "be creatable" do
|
27
|
+
reversal = @transfer.reversals.create(
|
28
|
+
amount: 100
|
29
|
+
)
|
30
|
+
assert_requested :post,
|
31
|
+
"#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals"
|
32
|
+
assert reversal.kind_of?(Stripe::Reversal)
|
33
|
+
end
|
31
34
|
|
35
|
+
should "be saveable" do
|
36
|
+
reversal = @transfer.reversals.retrieve(FIXTURE[:id])
|
32
37
|
reversal.metadata['key'] = 'value'
|
33
38
|
reversal.save
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
should "create should return a new reversal" do
|
39
|
-
@mock.expects(:get).once.returns(make_response(make_transfer))
|
40
|
-
@mock.expects(:post).once.returns(make_response(make_reversal(:id => 'test_new_reversal')))
|
41
|
-
|
42
|
-
transfer = Stripe::Transfer.retrieve('test_transfer')
|
43
|
-
reversals = transfer.reversals.create(:amount => 20)
|
44
|
-
assert_equal 'test_new_reversal', reversals.id
|
39
|
+
assert_requested :post,
|
40
|
+
"#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals/#{FIXTURE[:id]}"
|
45
41
|
end
|
46
42
|
end
|
47
43
|
end
|
data/test/stripe/sku_test.rb
CHANGED
@@ -2,32 +2,49 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class SKUTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:sku)
|
6
|
+
|
7
|
+
should "be listable" do
|
8
8
|
skus = Stripe::SKU.list
|
9
|
-
|
10
|
-
skus.
|
11
|
-
|
12
|
-
end
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/skus"
|
10
|
+
assert skus.data.kind_of?(Array)
|
11
|
+
assert skus.data[0].kind_of?(Stripe::SKU)
|
13
12
|
end
|
14
13
|
|
15
|
-
should "
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
s = Stripe::SKU.update("test_sku", metadata: {foo: 'bar'})
|
20
|
-
assert_equal 'bar', s.metadata['foo']
|
14
|
+
should "be retrievable" do
|
15
|
+
sku = Stripe::SKU.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
|
17
|
+
assert sku.kind_of?(Stripe::SKU)
|
21
18
|
end
|
22
19
|
|
23
|
-
should "
|
24
|
-
|
25
|
-
|
20
|
+
should "be creatable" do
|
21
|
+
_ = Stripe::SKU.create(
|
22
|
+
currency: "USD",
|
23
|
+
inventory: { type: "finite", quantity: 500 },
|
24
|
+
price: 100,
|
25
|
+
product: API_FIXTURES.fetch(:product)[:id]
|
26
|
+
)
|
27
|
+
assert_requested :post, "#{Stripe.api_base}/v1/skus"
|
28
|
+
end
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
should "be saveable" do
|
31
|
+
sku = Stripe::SKU.retrieve(FIXTURE[:id])
|
32
|
+
sku.metadata['key'] = 'value'
|
33
|
+
sku.save
|
34
|
+
assert_requested :post, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
|
30
35
|
end
|
31
36
|
|
37
|
+
should "be updateable" do
|
38
|
+
sku = Stripe::SKU.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
39
|
+
assert_requested :post, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
|
40
|
+
assert sku.kind_of?(Stripe::SKU)
|
41
|
+
end
|
42
|
+
|
43
|
+
should "be deletable" do
|
44
|
+
sku = Stripe::SKU.retrieve(FIXTURE[:id])
|
45
|
+
sku = sku.delete
|
46
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
|
47
|
+
assert sku.kind_of?(Stripe::SKU)
|
48
|
+
end
|
32
49
|
end
|
33
50
|
end
|