From f51a4f25a954b5b516ad5dc75129d085828ae4b0 Mon Sep 17 00:00:00 2001 From: railscard Date: Mon, 14 Dec 2015 06:16:31 +0400 Subject: [PATCH] Allow http command to keep initial query parameters --- lib/google/apis/core/http_command.rb | 2 +- spec/google/apis/core/http_command_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/google/apis/core/http_command.rb b/lib/google/apis/core/http_command.rb index ee8915815..90c1c2723 100644 --- a/lib/google/apis/core/http_command.rb +++ b/lib/google/apis/core/http_command.rb @@ -143,7 +143,7 @@ module Google def prepare! header.update(options.header) if options && options.header self.url = url.expand(params) if url.is_a?(Addressable::Template) - url.query_values = query + url.query_values = query.merge(url.query_values || {}) end # Release any resources used by this command diff --git a/spec/google/apis/core/http_command_spec.rb b/spec/google/apis/core/http_command_spec.rb index c9445f791..8543e7175 100644 --- a/spec/google/apis/core/http_command_spec.rb +++ b/spec/google/apis/core/http_command_spec.rb @@ -264,4 +264,12 @@ RSpec.describe Google::Apis::Core::HttpCommand do command.query['a'] = [1,2,3] command.execute(client) end + + it 'should not remove initial query parameters' do + stub_request(:get, 'https://www.googleapis.com/zoo/animals?a=1&a=2&a=3&foo=bar') + .to_return(status: [200, '']) + command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals?foo=bar') + command.query['a'] = [1,2,3] + command.execute(client) + end end