Skip to content

Commit

Permalink
Merge pull request #410 from stripe/brandur-fix-warnings
Browse files Browse the repository at this point in the history
Fix warnings emitted during tests
  • Loading branch information
brandur committed Apr 11, 2016
2 parents 2663e9f + 8f55baa commit c98f555
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 10 deletions.
1 change: 0 additions & 1 deletion lib/stripe/api_operations/list.rb
Expand Up @@ -3,7 +3,6 @@ module APIOperations
module List
def list(filters={}, opts={})
opts = Util.normalize_opts(opts)
opts = @opts.merge(opts) if @opts

response, opts = request(:get, resource_url, filters, opts)
obj = ListObject.construct_from(response, opts)
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/charge.rb
Expand Up @@ -13,7 +13,7 @@ def refund(params={}, opts={})
# an `Array` and fall back to the old refund URL if necessary so as to
# maintain internal compatibility.
unless self.refunds.is_a?(Array)
refund = self.refunds.create(params, opts)
self.refunds.create(params, opts)

# now that a refund has been created, we expect the state of this object
# to change as well (i.e. `refunded` will now be `true`) so refresh it
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/stripe_object.rb
Expand Up @@ -32,7 +32,7 @@ def self.construct_from(values, opts={})
# considered to be equal if they have the same set of values and each one
# of those values is the same.
def ==(other)
@values == other.instance_variable_get(:@values)
other.is_a?(StripeObject) && @values == other.instance_variable_get(:@values)
end

# Indicates whether or not the resource has been deleted on the server.
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/subscription.rb
Expand Up @@ -12,7 +12,7 @@ def self.retrieve(id, opts=nil)
end

def delete_discount
response, opts = request(:delete, discount_url)
_, opts = request(:delete, discount_url)
initialize_from({ :discount => nil }, opts, true)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/transfer.rb
Expand Up @@ -5,7 +5,7 @@ class Transfer < APIResource
include Stripe::APIOperations::Update

def cancel
response, api_key = Stripe.request(:post, cancel_url, @api_key)
response, api_key = self.request(:post, cancel_url)
initialize_from(response, api_key)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/util.rb
Expand Up @@ -120,7 +120,7 @@ def self.flatten_params(params, parent_key=nil)

# do not sort the final output because arrays (and arrays of hashes
# especially) can be order sensitive, but do sort incoming parameters
params.sort_by { |(k, v)| k.to_s }.each do |key, value|
params.sort_by { |(k, _)| k.to_s }.each do |key, value|
calculated_key = parent_key ? "#{parent_key}[#{key}]" : "#{key}"
if value.is_a?(Hash)
result += flatten_params(value, calculated_key)
Expand Down
2 changes: 1 addition & 1 deletion test/stripe/api_resource_test.rb
Expand Up @@ -445,7 +445,7 @@ class ApiResourceTest < Test::Unit::TestCase
opts[:url] == "#{Stripe.api_base}/v1/customers/c_test_customer" &&
opts[:headers][:stripe_account] == 'acct_abc'
end.once.returns(make_response(make_customer))
c = Stripe::Customer.retrieve("c_test_customer", {:stripe_account => 'acct_abc'})
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
Expand Down
4 changes: 2 additions & 2 deletions test/stripe/bitcoin_receiver_test.rb
Expand Up @@ -47,14 +47,14 @@ class BitcoinReceiverTest < Test::Unit::TestCase
should "delete a bitcoin receiver with no customer through top-level API" do
@mock.expects(:delete).with("#{Stripe.api_base}/v1/bitcoin/receivers/btcrcv_test_receiver", nil, nil).once.returns(make_response({:deleted => true, :id => "btcrcv_test_receiver"}))
receiver = Stripe::BitcoinReceiver.construct_from(make_bitcoin_receiver)
response = receiver.delete
receiver.delete
assert(receiver.deleted)
end

should "delete a bitcoin receiver with a customer through customer's subresource API" do
@mock.expects(:delete).with("#{Stripe.api_base}/v1/customers/customer_foo/sources/btcrcv_test_receiver", nil, nil).once.returns(make_response({:deleted => true, :id => "btcrcv_test_receiver"}))
receiver = Stripe::BitcoinReceiver.construct_from(make_bitcoin_receiver(:customer => 'customer_foo'))
response = receiver.delete
receiver.delete
assert(receiver.deleted)
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/stripe/stripe_object_test.rb
Expand Up @@ -283,7 +283,7 @@ class StripeObjectTest < Test::Unit::TestCase
e = assert_raises ArgumentError do
obj.foo = ""
end
assert_match /\(object\).foo = nil/, e.message
assert_match %r{\(object\).foo = nil}, e.message
end
end
end
4 changes: 4 additions & 0 deletions test/test_helper.rb
Expand Up @@ -13,6 +13,10 @@ def self.mock_rest_client=(mock_client)
@mock_rest_client = mock_client
end

class << self
remove_method :execute_request
end

def self.execute_request(opts)
get_params = (opts[:headers] || {})[:params]
post_params = opts[:payload]
Expand Down

0 comments on commit c98f555

Please sign in to comment.