Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e078a173
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 搜索 >>
提交
e078a173
编写于
9月 03, 2012
作者:
A
Alex Denisov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create project via API: fixes added
上级
0c5e5569
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
8 deletion
+61
-8
doc/api/projects.md
doc/api/projects.md
+6
-0
lib/api/projects.rb
lib/api/projects.rb
+17
-5
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+38
-3
未找到文件。
doc/api/projects.md
浏览文件 @
e078a173
...
...
@@ -102,6 +102,12 @@ Parameters:
+
`name`
(required) - new project name
+
`code`
(optional) - new project code, uses project name if not set
+
`path`
(optional) - new project path, uses project name if not set
+
`description (optional) - short project description
+ `
default_branch
` (optional) - 'master' by default
+ `
issues_enabled
` (optional) - enabled by default
+ `
wall_enabled
` (optional) - enabled by default
+ `
merge_requests_enabled
` (optional) - enabled by default
+ `
wiki_enabled
` (optional) - enabled by default
Will return created project with status `
201 Created
` on success, or `
404 Not
found
` on fail.
...
...
lib/api/projects.rb
浏览文件 @
e078a173
...
...
@@ -29,14 +29,26 @@ module Gitlab
# name (required) - name for new project
# code (optional) - code for new project, uses project name if not set
# path (optional) - path for new project, uses project name if not set
# description (optional) - short project description
# default_branch (optional) - 'master' by default
# issues_enabled (optional) - enabled by default
# wall_enabled (optional) - enabled by default
# merge_requests_enabled (optional) - enabled by default
# wiki_enabled (optional) - enabled by default
# Example Request
# POST /projects
post
do
project
=
{}
project
[
:name
]
=
params
[
:name
]
project
[
:code
]
=
params
[
:code
]
||
project
[
:name
]
project
[
:path
]
=
params
[
:path
]
||
project
[
:name
]
@project
=
Project
.
create_by_user
(
project
,
current_user
)
@project
=
Project
.
create_by_user
({
name:
params
[
:name
],
code:
(
params
[
:code
]
||
params
[
:name
]),
path:
(
params
[
:path
]
||
params
[
:name
]),
description:
(
params
[
:description
]
||
Project
.
columns_hash
[
"description"
].
default
),
default_branch:
(
params
[
:default_branch
]
||
Project
.
columns_hash
[
"default_branch"
].
default
),
issues_enabled:
(
params
[
:issues_enabled
]
||
Project
.
columns_hash
[
"issues_enabled"
].
default
),
wall_enabled:
(
params
[
:wall_enabled
]
||
Project
.
columns_hash
[
"wall_enabled"
].
default
),
merge_requests_enabled:
(
params
[
:merge_requests_enabled
]
||
Project
.
columns_hash
[
"merge_requests_enabled"
].
default
),
wiki_enabled:
(
params
[
:wiki_enabled
]
||
Project
.
columns_hash
[
"wiki_enabled"
].
default
)
},
current_user
)
if
@project
.
saved?
present
@project
,
with:
Entities
::
Project
else
...
...
spec/requests/api/projects_spec.rb
浏览文件 @
e078a173
...
...
@@ -27,7 +27,7 @@ describe Gitlab::API do
describe
"POST /projects"
do
it
"should create new project without code and path"
do
lambda
{
expect
{
name
=
"foo"
post
api
(
"/projects"
,
user
),
{
name:
name
...
...
@@ -39,7 +39,41 @@ describe Gitlab::API do
}.
should
change
{
Project
.
count
}.
by
(
1
)
end
it
"should create new project"
do
lambda
{
expect
{
name
=
"foo"
path
=
"bar"
code
=
"bazz"
description
=
"fuu project"
default_branch
=
"default_branch"
issues_enabled
=
false
wall_enabled
=
false
merge_requests_enabled
=
false
wiki_enabled
=
false
post
api
(
"/projects"
,
user
),
{
code:
code
,
path:
path
,
name:
name
,
description:
description
,
default_branch:
default_branch
,
issues_enabled:
issues_enabled
,
wall_enabled:
wall_enabled
,
merge_requests_enabled:
merge_requests_enabled
,
wiki_enabled:
wiki_enabled
}
response
.
status
.
should
==
201
json_response
[
"name"
].
should
==
name
json_response
[
"path"
].
should
==
path
json_response
[
"code"
].
should
==
code
json_response
[
"description"
].
should
==
description
json_response
[
"default_branch"
].
should
==
default_branch
json_response
[
"issues_enabled"
].
should
==
issues_enabled
json_response
[
"wall_enabled"
].
should
==
wall_enabled
json_response
[
"merge_requests_enabled"
].
should
==
merge_requests_enabled
json_response
[
"wiki_enabled"
].
should
==
wiki_enabled
}.
should
change
{
Project
.
count
}.
by
(
1
)
end
it
"should create new projects within all parameters"
do
expect
{
name
=
"foo"
path
=
"bar"
code
=
"bazz"
...
...
@@ -53,9 +87,10 @@ describe Gitlab::API do
json_response
[
"path"
].
should
==
path
json_response
[
"code"
].
should
==
code
}.
should
change
{
Project
.
count
}.
by
(
1
)
end
it
"should not create project without name"
do
lambda
{
expect
{
post
api
(
"/projects"
,
user
)
response
.
status
.
should
==
404
}.
should_not
change
{
Project
.
count
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录