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
Léo-Paul Géneau
gitlab-ce
Commits
1a3bcc76
Commit
1a3bcc76
authored
Jan 17, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the user-agent detail API endpoint for project snippets
parent
f17d7a4b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
doc/api/project_snippets.md
doc/api/project_snippets.md
+5
-4
lib/api/project_snippets.rb
lib/api/project_snippets.rb
+1
-1
spec/requests/api/project_snippets_spec.rb
spec/requests/api/project_snippets_spec.rb
+10
-3
No files found.
doc/api/project_snippets.md
View file @
1a3bcc76
...
...
@@ -131,12 +131,13 @@ Available only for admins.
GET /projects/:id/snippets/:snippet_id/user_agent_detail
```
| Attribute | Type | Required | Description |
|-------------|---------|----------|--------------------------------------|
|
`id`
| Integer | yes | The ID of a snippet |
| Attribute | Type | Required | Description |
|---------------|---------|----------|--------------------------------------|
|
`id`
| Integer | yes | The ID of a project |
|
`snippet_id`
| Integer | yes | The ID of a snippet |
```
bash
curl
--request
GET
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/projects/1/snippets/
1
/user_agent_detail
curl
--request
GET
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/projects/1/snippets/
2
/user_agent_detail
```
Example response:
...
...
lib/api/project_snippets.rb
View file @
1a3bcc76
...
...
@@ -143,7 +143,7 @@ module API
get
":id/snippets/:snippet_id/user_agent_detail"
do
authenticated_as_admin!
snippet
=
Snippet
.
find_by!
(
id:
params
[
:id
])
snippet
=
Snippet
.
find_by!
(
id:
params
[
:
snippet_id
],
project_id:
params
[
:
id
])
return
not_found!
(
'UserAgentDetail'
)
unless
snippet
.
user_agent_detail
...
...
spec/requests/api/project_snippets_spec.rb
View file @
1a3bcc76
require
'rails_helper'
describe
API
::
ProjectSnippets
do
l
et
(
:project
)
{
create
(
:project
,
:public
)
}
l
et
(
:user
)
{
create
(
:user
)
}
l
et
(
:admin
)
{
create
(
:admin
)
}
s
et
(
:project
)
{
create
(
:project
,
:public
)
}
s
et
(
:user
)
{
create
(
:user
)
}
s
et
(
:admin
)
{
create
(
:admin
)
}
describe
"GET /projects/:project_id/snippets/:id/user_agent_detail"
do
let
(
:snippet
)
{
create
(
:project_snippet
,
:public
,
project:
project
)
}
...
...
@@ -18,6 +18,13 @@ describe API::ProjectSnippets do
expect
(
json_response
[
'akismet_submitted'
]).
to
eq
(
user_agent_detail
.
submitted
)
end
it
'respects project scoping'
do
other_project
=
create
(
:project
)
get
api
(
"/projects/
#{
other_project
.
id
}
/snippets/
#{
snippet
.
id
}
/user_agent_detail"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
"returns unautorized for non-admin users"
do
get
api
(
"/projects/
#{
snippet
.
project
.
id
}
/snippets/
#{
snippet
.
id
}
/user_agent_detail"
,
user
)
...
...
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