Commit cf84a3a6 authored by Gilbert's avatar Gilbert
Browse files

Make plan_id string/symbol agnostic [fixes #87]

parent 256625da
......@@ -22,8 +22,9 @@ module StripeMock
customers[ params[:id] ] = Data.mock_customer(cards, params)
if params[:plan]
plan = plans[ params[:plan] ]
assert_existance :plan, params[:plan], plan
plan_id = params[:plan].to_s
plan = plans[plan_id]
assert_existance :plan, plan_id, plan
if params[:default_card].nil? && plan[:trial_period_days].nil? && plan[:amount] != 0
raise Stripe::InvalidRequestError.new('You must supply a valid card', nil, 400)
......
......@@ -11,7 +11,7 @@ module StripeMock
end
def new_plan(route, method_url, params, headers)
params[:id] ||= new_id('plan')
params[:id] = ( params[:id] || new_id('plan') ).to_s
plans[ params[:id] ] = Data.mock_plan(params)
end
......
......@@ -47,6 +47,20 @@ shared_examples 'Customer API' do
expect(customer.subscriptions.first.customer).to eq(customer.id)
end
it "creates a customer with a plan (string/symbol agnostic)" do
plan = Stripe::Plan.create(id: 'string_id')
customer = Stripe::Customer.create(id: 'test_cus_plan', card: 'tk', :plan => :string_id)
customer = Stripe::Customer.retrieve('test_cus_plan')
expect(customer.subscriptions.first.plan.id).to eq('string_id')
plan = Stripe::Plan.create(:id => :sym_id)
customer = Stripe::Customer.create(id: 'test_cus_plan', card: 'tk', :plan => 'sym_id')
customer = Stripe::Customer.retrieve('test_cus_plan')
expect(customer.subscriptions.first.plan.id).to eq('sym_id')
end
context "create customer" do
it "with a trial when trial_end is set" do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment