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
a9e8af33
Commit
a9e8af33
authored
Jul 07, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add spec and project snippet user agent details endpoint
parent
5173955f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
0 deletions
+39
-0
doc/api/project_snippets.md
doc/api/project_snippets.md
+1
-0
doc/api/snippets.md
doc/api/snippets.md
+1
-0
lib/api/project_snippets.rb
lib/api/project_snippets.rb
+16
-0
spec/requests/api/project_snippets_spec.rb
spec/requests/api/project_snippets_spec.rb
+21
-0
No files found.
doc/api/project_snippets.md
View file @
a9e8af33
...
...
@@ -149,4 +149,5 @@ Example response:
"akismet_submitted"
:
false
}
```
[
ce-[ce-29508
]:
https://gitlab.com/gitlab-org/gitlab-ce/issues/29508]:
https://gitlab.com/gitlab-org/gitlab-ce/issues/29508
doc/api/snippets.md
View file @
a9e8af33
...
...
@@ -264,4 +264,5 @@ Example response:
"akismet_submitted"
:
false
}
```
[
ce-[ce-29508
]:
https://gitlab.com/gitlab-org/gitlab-ce/issues/29508]:
https://gitlab.com/gitlab-org/gitlab-ce/issues/29508
lib/api/project_snippets.rb
View file @
a9e8af33
...
...
@@ -131,6 +131,22 @@ module API
content_type
'text/plain'
present
snippet
.
content
end
desc
'Get the user agent details for a project snippet'
do
success
Entities
::
UserAgentDetail
end
params
do
requires
:snippet_id
,
type:
Integer
,
desc:
'The ID of a project snippet'
end
get
":id/snippets/:snippet_id/user_agent_detail"
do
authenticated_as_admin!
snippet
=
Snippet
.
find_by!
(
id:
params
[
:id
])
return
not_found!
(
'UserAgentDetail'
)
unless
snippet
.
user_agent_detail
present
snippet
.
user_agent_detail
,
with:
Entities
::
UserAgentDetail
end
end
end
end
spec/requests/api/project_snippets_spec.rb
View file @
a9e8af33
...
...
@@ -242,4 +242,25 @@ describe API::ProjectSnippets do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Snippet Not Found'
)
end
end
describe
"GET /projects/:project_id/snippets/:id/user_agent_detail"
do
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:snippet
)
{
create
(
:project_snippet
,
author:
admin
)
}
let!
(
:user_agent_detail
)
{
create
(
:user_agent_detail
,
subject:
snippet
)
}
it
'exposes known attributes'
do
get
api
(
"/projects/
#{
snippet
.
project
.
id
}
/snippets/
#{
snippet
.
id
}
/user_agent_detail"
,
admin
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'user_agent'
]).
to
eq
(
user_agent_detail
.
user_agent
)
expect
(
json_response
[
'ip_address'
]).
to
eq
(
user_agent_detail
.
ip_address
)
expect
(
json_response
[
'akismet_submitted'
]).
to
eq
(
user_agent_detail
.
submitted
)
end
it
"returns unautorized for non-admin users"
do
get
api
(
"/projects/
#{
snippet
.
project
.
id
}
/snippets/
#{
snippet
.
id
}
/user_agent_detail"
,
user
)
expect
(
response
).
to
have_http_status
(
403
)
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