Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
3ab9ea8d
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,体验更适合开发者的 AI 搜索 >>
提交
3ab9ea8d
编写于
4月 12, 2016
作者:
R
Robert Schilling
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make staring API more restful
上级
ea2193aa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
16 deletion
+15
-16
doc/api/projects.md
doc/api/projects.md
+6
-6
lib/api/projects.rb
lib/api/projects.rb
+5
-6
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+4
-4
未找到文件。
doc/api/projects.md
浏览文件 @
3ab9ea8d
...
...
@@ -493,8 +493,8 @@ Parameters:
### Star a project
Stars a given project. Returns status code
201
and the project on success and
304
if the project is already starred.
Stars a given project. Returns status code
`201`
and the project on success and
`304`
if the project is already starred.
```
POST /projects/:id/star
...
...
@@ -556,11 +556,11 @@ Example response:
### Unstar a project
Unstars a given project. Returns status code
201
and the project on success
and
304 if the project is already un
starred.
Unstars a given project. Returns status code
`200`
and the project on success
and
`304`
if the project is not
starred.
```
POST /projects/:id/un
star
DELETE /projects/:id/
star
```
| Attribute | Type | Required | Description |
...
...
@@ -568,7 +568,7 @@ POST /projects/:id/unstar
|
`id`
| integer | yes | The ID of the project |
```
bash
curl
-X
POST
-H
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
"https://gitlab.example.com/api/v3/projects/5/un
star"
curl
-X
DELETE
-H
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
"https://gitlab.example.com/api/v3/projects/5/
star"
```
Example response:
...
...
lib/api/projects.rb
浏览文件 @
3ab9ea8d
...
...
@@ -279,13 +279,12 @@ module API
# Example Request:
# POST /projects/:id/star
post
':id/star'
do
if
!
current_user
.
starred?
(
user_project
)
if
current_user
.
starred?
(
user_project
)
not_modified!
else
current_user
.
toggle_star
(
user_project
)
user_project
.
reload
present
user_project
,
with:
Entities
::
Project
else
not_modified!
end
end
...
...
@@ -294,8 +293,8 @@ module API
# Parameters:
# id (required) - The ID of a project
# Example Request:
#
POST
/projects/:id/unstar
post
':id/un
star'
do
#
DELETE
/projects/:id/unstar
delete
':id/
star'
do
if
current_user
.
starred?
(
user_project
)
current_user
.
toggle_star
(
user_project
)
user_project
.
reload
...
...
spec/requests/api/projects_spec.rb
浏览文件 @
3ab9ea8d
...
...
@@ -1045,7 +1045,7 @@ describe API::API, api: true do
end
end
describe
'
POST /projects/:id/un
star'
do
describe
'
DELETE /projects/:id/
star'
do
context
'on a starred project'
do
before
do
user
.
toggle_star
(
project
)
...
...
@@ -1053,16 +1053,16 @@ describe API::API, api: true do
end
it
'unstars the project'
do
post
api
(
"/projects/
#{
project
.
id
}
/un
star"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/
star"
,
user
)
expect
(
response
.
status
).
to
eq
(
20
1
)
expect
(
response
.
status
).
to
eq
(
20
0
)
expect
(
json_response
[
'star_count'
]).
to
eq
(
0
)
end
end
context
'on an unstarred project'
do
it
'does not modify the star count'
do
post
api
(
"/projects/
#{
project
.
id
}
/un
star"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/
star"
,
user
)
expect
(
response
.
status
).
to
eq
(
304
)
expect
(
project
.
star_count
).
to
eq
(
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录