Use RequestOptions in GCP Client user_agent_header

This commit is contained in:
Matija Čupić 2017-12-04 01:59:29 +01:00
parent 50c8bd6350
commit 04c6d10261
No known key found for this signature in database
GPG Key ID: 4BAF84FFACD2E5DE
2 changed files with 10 additions and 3 deletions

View File

@ -84,7 +84,9 @@ module GoogleApi
end
def user_agent_header
{ 'User-Agent': "GitLab/#{Gitlab::VERSION.match('(\d+\.\d+)').captures.first} (GPN:GitLab;)" }
options = Google::Apis::RequestOptions.new
options.header = { 'User-Agent': "GitLab/#{Gitlab::VERSION.match('(\d+\.\d+)').captures.first} (GPN:GitLab;)" }
options
end
end
end

View File

@ -129,9 +129,14 @@ describe GoogleApi::CloudPlatform::Client do
describe '#user_agent_header' do
subject { client.instance_eval { user_agent_header } }
it 'returns the correct major and minor GitLab version ' do
it 'returns a RequestOptions object' do
expect(subject).to be_instance_of(Google::Apis::RequestOptions)
end
it 'has the correct GitLab version in User-Agent header' do
stub_const('Gitlab::VERSION', '10.3.0-pre')
expect(subject).to eq({ 'User-Agent': 'GitLab/10.3 (GPN:GitLab;)' })
expect(subject.header).to eq({ 'User-Agent': 'GitLab/10.3 (GPN:GitLab;)' })
end
end
end