Skip to content

Commit

Permalink
fix: fixed query param not going for delete (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
manisha1997 authored Jan 2, 2024
1 parent 9db1a24 commit cec034b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/twilio-ruby/http/http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Twilio
module HTTP
class Client
attr_accessor :adapter
attr_reader :timeout, :last_response, :last_request
attr_reader :timeout, :last_response, :last_request, :connection

def initialize(proxy_prot = nil, proxy_addr = nil, proxy_port = nil, proxy_user = nil, proxy_pass = nil,
ssl_ca_file = nil, timeout: nil)
Expand Down Expand Up @@ -39,6 +39,7 @@ def _request(request) # rubocop:disable Metrics/MethodLength
f.proxy = "#{@proxy_prot}://#{@proxy_auth}#{@proxy_path}" if @proxy_prot && @proxy_path
f.options.open_timeout = request.timeout || @timeout
f.options.timeout = request.timeout || @timeout
f.params = request.params.nil? ? {} : request.params

@configure_connection_blocks.each { |block| block.call(f) }
f.adapter @adapter
Expand All @@ -65,7 +66,7 @@ def _request(request) # rubocop:disable Metrics/MethodLength
def send(request)
@connection.send(request.method.downcase.to_sym,
request.url,
request.method == 'GET' ? request.params : request.data)
request.data)
rescue Faraday::Error => e
raise Twilio::REST::TwilioError, e
end
Expand Down
7 changes: 7 additions & 0 deletions spec/http/http_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@
expect(@client.last_request.timeout).to be_nil
end

it 'should contain params in Connection object' do
allow_any_instance_of(Faraday::Connection).to receive(:send).and_return(double('response', status: 301, body: {}, headers: { something: '1' }))
params = Twilio::Values.of({ 'abc' => 'xyz' })
@client.request('host', 'port', 'DELETE', 'url', params, nil, {}, ['a', 'b'])
expect(@client.connection.params).to eq({ 'abc' => 'xyz' })
end

describe 'last_response' do
let(:last_response) { Twilio::Response.new(200, 'body') }
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require 'twilio-ruby'
require 'rspec/matchers'
require 'equivalent-xml'
require 'rspec/core'

RSpec.configure do |config|
config.expect_with :rspec do |c|
Expand Down

0 comments on commit cec034b

Please sign in to comment.