mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-05 00:02:50 -04:00
Usage on a top-level collection: ``` Stripe::Customer.list.auto_paging_each do |customer| puts customer end ``` Usage on a subcollection: ``` ruby customer.invoices.auto_paging_each do |invoice| puts invoice end ``` We've also renamed `#all` to `#list` to prevent confusion ("all" implies that all resources are being returned, and in Stripe's paginated API this was not the case). An alias has been provided for backward API compatibility. Fixes #167. Replaces #211 and #248.
42 lines
1.3 KiB
Ruby
42 lines
1.3 KiB
Ruby
require File.expand_path('../../test_helper', __FILE__)
|
|
|
|
module Stripe
|
|
class ProductTest < Test::Unit::TestCase
|
|
should "products should be listable" do
|
|
@mock.expects(:get).once.returns(make_response(make_product_array))
|
|
products = Stripe::Product.list
|
|
assert products.data.kind_of?(Array)
|
|
products.each do |product|
|
|
assert product.kind_of?(Stripe::Product)
|
|
end
|
|
end
|
|
|
|
should "products should not be deletable" do
|
|
assert_raises NoMethodError do
|
|
@mock.expects(:get).once.returns(make_response(make_product))
|
|
p = Stripe::Product.retrieve("test_product")
|
|
p.delete
|
|
end
|
|
end
|
|
|
|
should "products should be updateable" do
|
|
@mock.expects(:get).once.returns(make_response(make_product))
|
|
@mock.expects(:post).once.returns(make_response(make_product))
|
|
p = Stripe::Product.new("test_product")
|
|
p.refresh
|
|
p.description = "New product description"
|
|
p.save
|
|
end
|
|
|
|
should "products should allow metadata updates" do
|
|
@mock.expects(:get).once.returns(make_response(make_product))
|
|
@mock.expects(:post).once.returns(make_response(make_product))
|
|
p = Stripe::Product.new("test_product")
|
|
p.refresh
|
|
p.metadata['key'] = 'value'
|
|
p.save
|
|
end
|
|
|
|
end
|
|
end
|