Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
1a3bcc76
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1a3bcc76
编写于
1月 17, 2018
作者:
N
Nick Thomas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the user-agent detail API endpoint for project snippets
上级
f17d7a4b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
8 deletion
+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
未找到文件。
doc/api/project_snippets.md
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录