Merge branch 'master' of github.com:stripe/stripe-ruby into ms

This commit is contained in:
Jim Danz 2014-01-29 14:59:33 -08:00
commit 02b1b05eef
6 changed files with 41 additions and 1 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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")

View File

@ -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

View 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