Skip to content

Commit

Permalink
Test URI is used correctly in http client
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Aug 4, 2023
1 parent 631b0e9 commit ab0863d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 2 additions & 4 deletions hearth/lib/hearth/http/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,8 @@ def configure_ssl(http)
# @param [Http::Request] request
# @return [Net::HTTP::Request]
def build_net_request(request)
req = net_http_request_class(request).new(
request.uri.request_uri,
net_headers_for(request)
)
request_class = net_http_request_class(request)
req = request_class.new(request.uri, net_headers_for(request))

# Net::HTTP adds a default Content-Type when a body is present.
# Set the body stream when it has an unknown size or when it is > 0.
Expand Down
4 changes: 3 additions & 1 deletion hearth/spec/hearth/http/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module HTTP
end

let(:http_method) { :get }
let(:uri) { URI('http://example.com') }
let(:uri) { URI('http://example.com/some/path?query') }
let(:fields) { Fields.new }
let(:request_body) { StringIO.new('') }

Expand All @@ -65,6 +65,8 @@ module HTTP
describe '#transmit' do
it 'sends the request to the uri' do
stub_request(:any, uri.to_s)
expect(Net::HTTP::Get).to receive(:new)
.with(request.uri, anything).and_call_original
subject.transmit(request: request, response: response)
end

Expand Down

0 comments on commit ab0863d

Please sign in to comment.