mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-09-22 00:00:31 -04:00
Merge branch 'master' of github.com:stripe/stripe-ruby into ms
This commit is contained in:
commit
02b1b05eef
@ -4,6 +4,7 @@ rvm:
|
||||
- 1.9.2
|
||||
- 1.9.3
|
||||
- 2.0.0
|
||||
- 2.1.0
|
||||
gemfile:
|
||||
- gemfiles/default-with-activesupport.gemfile
|
||||
- gemfiles/json.gemfile
|
||||
|
@ -25,6 +25,10 @@ module Stripe
|
||||
Charge.all({ :customer => id }, @api_key)
|
||||
end
|
||||
|
||||
def create_upcoming_invoice(params={})
|
||||
Invoice.create(params.merge(:customer => id), @api_key)
|
||||
end
|
||||
|
||||
def cancel_subscription(params={})
|
||||
response, api_key = Stripe.request(:delete, subscription_url, @api_key, params)
|
||||
refresh_from({ :subscription => response }, api_key, true)
|
||||
|
@ -102,6 +102,12 @@ module Stripe
|
||||
@values.each(&blk)
|
||||
end
|
||||
|
||||
if RUBY_VERSION < '1.9.2'
|
||||
def respond_to?(symbol)
|
||||
@values.has_key?(symbol) || super
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def metaclass
|
||||
@ -164,5 +170,9 @@ module Stripe
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def respond_to_missing?(symbol, include_private = false)
|
||||
@values.has_key?(symbol) || super
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -32,6 +32,12 @@ module Stripe
|
||||
assert_equal "c_test_customer", c.id
|
||||
end
|
||||
|
||||
should "create_upcoming_invoice should create a new invoice" do
|
||||
@mock.expects(:post).once.returns(test_response(test_invoice))
|
||||
i = Stripe::Customer.new("test_customer").create_upcoming_invoice
|
||||
assert_equal "c_test_customer", i.customer
|
||||
end
|
||||
|
||||
should "be able to update a customer's subscription" do
|
||||
@mock.expects(:get).once.returns(test_response(test_customer))
|
||||
c = Stripe::Customer.retrieve("test_customer")
|
||||
|
@ -8,6 +8,12 @@ module Stripe
|
||||
assert_equal 'in_test_invoice', i.id
|
||||
end
|
||||
|
||||
should "create should create a new invoice" do
|
||||
@mock.expects(:post).once.returns(test_response(test_invoice))
|
||||
i = Stripe::Invoice.create
|
||||
assert_equal "in_test_invoice", i.id
|
||||
end
|
||||
|
||||
should "pay should pay an invoice" do
|
||||
@mock.expects(:get).once.returns(test_response(test_invoice))
|
||||
i = Stripe::Invoice.retrieve('in_test_invoice')
|
||||
@ -17,4 +23,4 @@ module Stripe
|
||||
assert_equal i.next_payment_attempt, nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
13
test/stripe/stripe_object_test.rb
Normal file
13
test/stripe/stripe_object_test.rb
Normal file
@ -0,0 +1,13 @@
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
module Stripe
|
||||
class StripeObjectTest < Test::Unit::TestCase
|
||||
should "implement #respond_to correctly" do
|
||||
obj = Stripe::StripeObject.construct_from({ :some_key => "something", :id => 123 })
|
||||
|
||||
assert obj.respond_to?(:id)
|
||||
assert obj.respond_to?(:some_key)
|
||||
assert !obj.respond_to?(:some_other_key)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user