paypal / paypalhttp_ruby

MIT License
6 stars 38 forks source link

Error sending requests after gem update to 1.0.1 #14

Open aglushkov opened 3 years ago

aglushkov commented 3 years ago

General information

Issue description

  FrozenError:
    can't modify frozen String: "application/json"
# /usr/local/bundle/gems/paypalhttp-1.0.1/lib/paypalhttp/http_client.rb:35:in `downcase!'
# /usr/local/bundle/gems/paypalhttp-1.0.1/lib/paypalhttp/http_client.rb:35:in `block in format_headers'
# /usr/local/bundle/gems/paypalhttp-1.0.1/lib/paypalhttp/http_client.rb:30:in `each'
# /usr/local/bundle/gems/paypalhttp-1.0.1/lib/paypalhttp/http_client.rb:30:in `format_headers'
# /usr/local/bundle/gems/paypalhttp-1.0.1/lib/paypalhttp/http_client.rb:97:in `_parse_response'
# /usr/local/bundle/gems/paypalhttp-1.0.1/lib/paypalhttp/http_client.rb:87:in `block in execute'
# /usr/local/bundle/gems/webmock-3.14.0/lib/webmock/http_lib_adapters/net_http.rb:123:in `start_without_connect'
# /usr/local/bundle/gems/webmock-3.14.0/lib/webmock/http_lib_adapters/net_http.rb:150:in `start'
# /usr/local/bundle/gems/paypalhttp-1.0.1/lib/paypalhttp/http_client.rb:86:in `execute'
# /usr/local/bundle/gems/paypal-checkout-sdk-1.0.4/lib/core/paypal_http_client.rb:32:in `_sign_request'
# /usr/local/bundle/gems/paypalhttp-1.0.1/lib/paypalhttp/http_client.rb:66:in `block in execute'
# /usr/local/bundle/gems/paypalhttp-1.0.1/lib/paypalhttp/http_client.rb:65:in `each'
# /usr/local/bundle/gems/paypalhttp-1.0.1/lib/paypalhttp/http_client.rb:65:in `execute'
aglushkov commented 3 years ago

It is happens only in tests because I mocked paypal response with frozen headers:

      # frozen_string_literal: true
      # ...
      stub_request(:post, 'https://api.sandbox.paypal.com/v2/checkout/orders')
        .to_return(
          status: 200,
          body: { id: 'PAY-1B56960729604235TKQQIYVY' }.to_json,
          headers: { 'Content-Type' => 'application/json' }
        )

It looks currently like issue of webmock gem, but changing code here from downcase! to downcase is not a big deal