Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
04c6d102
Commit
04c6d102
authored
Dec 04, 2017
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use RequestOptions in GCP Client user_agent_header
parent
50c8bd63
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
lib/google_api/cloud_platform/client.rb
lib/google_api/cloud_platform/client.rb
+3
-1
spec/lib/google_api/cloud_platform/client_spec.rb
spec/lib/google_api/cloud_platform/client_spec.rb
+7
-2
No files found.
lib/google_api/cloud_platform/client.rb
View file @
04c6d102
...
@@ -84,7 +84,9 @@ module GoogleApi
...
@@ -84,7 +84,9 @@ module GoogleApi
end
end
def
user_agent_header
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
end
end
end
...
...
spec/lib/google_api/cloud_platform/client_spec.rb
View file @
04c6d102
...
@@ -129,9 +129,14 @@ describe GoogleApi::CloudPlatform::Client do
...
@@ -129,9 +129,14 @@ describe GoogleApi::CloudPlatform::Client do
describe
'#user_agent_header'
do
describe
'#user_agent_header'
do
subject
{
client
.
instance_eval
{
user_agent_header
}
}
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'
)
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
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment