test/stripe/api_resource_test.rb in stripe-1.18.0 vs test/stripe/api_resource_test.rb in stripe-1.19.0
- old
+ new
@@ -65,10 +65,27 @@
assert_equal(true, !!e.json_body[:error][:message])
assert_equal(test_invalid_api_key_error[:error][:message], e.json_body[:error][:message])
end
end
+ should "send expand on fetch properly" do
+ @mock.expects(:get).once.
+ with("#{Stripe.api_base}/v1/charges/ch_test_charge?expand[]=customer", nil, nil).
+ returns(test_response(test_charge))
+
+ Stripe::Charge.retrieve({:id => 'ch_test_charge', :expand => [:customer]})
+ end
+
+ should "preserve expand across refreshes" do
+ @mock.expects(:get).twice.
+ with("#{Stripe.api_base}/v1/charges/ch_test_charge?expand[]=customer", nil, nil).
+ returns(test_response(test_charge))
+
+ ch = Stripe::Charge.retrieve({:id => 'ch_test_charge', :expand => [:customer]})
+ ch.refresh
+ end
+
should "send stripe account as header when set" do
stripe_account = "acct_0000"
Stripe.expects(:execute_request).with do |opts|
opts[:headers][:stripe_account] == stripe_account
end.returns(test_response(test_charge))
@@ -292,11 +309,10 @@
should "deleting should send no props and result in an object that has no props other deleted" do
@mock.expects(:get).never
@mock.expects(:post).never
@mock.expects(:delete).with("#{Stripe.api_base}/v1/customers/c_test_customer", nil, nil).once.returns(test_response({ "id" => "test_customer", "deleted" => true }))
-
c = Stripe::Customer.construct_from(test_customer)
c.delete
assert_equal true, c.deleted
assert_raises NoMethodError do
@@ -314,9 +330,36 @@
@mock.expects(:get).once.returns(test_response(test_charge_array))
c = Stripe::Charge.all.data
assert c.kind_of? Array
assert c[0].kind_of? Stripe::Charge
assert c[0].card.kind_of?(Stripe::StripeObject) && c[0].card.object == 'card'
+ end
+
+ should "passing in a stripe_account header should pass it through on call" do
+ Stripe.expects(:execute_request).with do |opts|
+ opts[:method] == :get &&
+ opts[:url] == "#{Stripe.api_base}/v1/customers/c_test_customer" &&
+ opts[:headers][:stripe_account] == 'acct_abc'
+ end.once.returns(test_response(test_customer))
+ c = Stripe::Customer.retrieve("c_test_customer", {:stripe_account => 'acct_abc'})
+ end
+
+ should "passing in a stripe_account header should pass it through on save" do
+ Stripe.expects(:execute_request).with do |opts|
+ opts[:method] == :get &&
+ opts[:url] == "#{Stripe.api_base}/v1/customers/c_test_customer" &&
+ opts[:headers][:stripe_account] == 'acct_abc'
+ end.once.returns(test_response(test_customer))
+ c = Stripe::Customer.retrieve("c_test_customer", {:stripe_account => 'acct_abc'})
+
+ Stripe.expects(:execute_request).with do |opts|
+ opts[:method] == :post &&
+ opts[:url] == "#{Stripe.api_base}/v1/customers/c_test_customer" &&
+ opts[:headers][:stripe_account] == 'acct_abc' &&
+ opts[:payload] == 'description=FOO'
+ end.once.returns(test_response(test_customer))
+ c.description = 'FOO'
+ c.save
end
context "error checking" do
should "404s should raise an InvalidRequestError" do