mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-11-22 00:05:58 -05:00
Merge pull request #743 from stripe/brandur-remove-file-encoding
Remove attempt to nicen `UploadIO` in logs
This commit is contained in:
commit
65cc699832
@ -219,7 +219,7 @@ module Stripe
|
||||
# will throw away the result of this encoder and build its body.
|
||||
def encode(hash)
|
||||
@cache.fetch(hash) do |k|
|
||||
@cache[k] = Util.encode_parameters(replace_faraday_io(hash))
|
||||
@cache[k] = Util.encode_parameters(hash)
|
||||
end
|
||||
end
|
||||
|
||||
@ -227,26 +227,6 @@ module Stripe
|
||||
def decode(_str)
|
||||
raise NotImplementedError, "#{self.class.name} does not implement #decode"
|
||||
end
|
||||
|
||||
# Replaces instances of `Faraday::UploadIO` with a simple string
|
||||
# representation so that they'll log a little better. Faraday won't use
|
||||
# these parameters, so it's okay that we did this.
|
||||
#
|
||||
# Unfortunately the string representation still doesn't look very nice
|
||||
# because we still URL-encode special symbols in the final value. It's
|
||||
# possible we could stop doing this and just leave it to Faraday to do
|
||||
# the right thing.
|
||||
private def replace_faraday_io(value)
|
||||
if value.is_a?(Array)
|
||||
value.each_with_index { |v, i| value[i] = replace_faraday_io(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
value.each { |k, v| value[k] = replace_faraday_io(v) }
|
||||
elsif value.is_a?(Faraday::UploadIO)
|
||||
"FILE:#{value.original_filename}"
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def api_url(url = "", api_base = nil)
|
||||
|
||||
@ -794,16 +794,6 @@ module Stripe
|
||||
assert(!trace_payload["last_request_metrics"]["request_duration_ms"].nil?)
|
||||
end
|
||||
end
|
||||
|
||||
context "FaradayStripeEncoder" do
|
||||
should "replace Faraday::UploadIO instances in parameters" do
|
||||
encoder = StripeClient::FaradayStripeEncoder.new
|
||||
encoded = encoder.encode(foo: [
|
||||
{ file: Faraday::UploadIO.new(::File.new(__FILE__), nil) },
|
||||
])
|
||||
assert_equal "foo[0][file]=FILE%3Astripe_client_test.rb", encoded
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class SystemProfilerTest < Test::Unit::TestCase
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user