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
e078a173
Commit
e078a173
authored
Sep 03, 2012
by
Alex Denisov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create project via API: fixes added
parent
0c5e5569
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
8 deletions
+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
No files found.
doc/api/projects.md
View file @
e078a173
...
@@ -102,6 +102,12 @@ Parameters:
...
@@ -102,6 +102,12 @@ Parameters:
+
`name`
(required) - new project name
+
`name`
(required) - new project name
+
`code`
(optional) - new project code, uses project name if not set
+
`code`
(optional) - new project code, uses project name if not set
+
`path`
(optional) - new project path, 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
Will return created project with status `
201 Created
` on success, or `
404 Not
found
` on fail.
found
` on fail.
...
...
lib/api/projects.rb
View file @
e078a173
...
@@ -29,14 +29,26 @@ module Gitlab
...
@@ -29,14 +29,26 @@ module Gitlab
# name (required) - name for new project
# name (required) - name for new project
# code (optional) - code for new project, uses project name if not set
# code (optional) - code for new project, uses project name if not set
# path (optional) - path 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
# Example Request
# POST /projects
# POST /projects
post
do
post
do
project
=
{}
@project
=
Project
.
create_by_user
({
project
[
:name
]
=
params
[
:name
]
name:
params
[
:name
],
project
[
:code
]
=
params
[
:code
]
||
project
[
:name
]
code:
(
params
[
:code
]
||
params
[
:name
]),
project
[
:path
]
=
params
[
:path
]
||
project
[
:name
]
path:
(
params
[
:path
]
||
params
[
:name
]),
@project
=
Project
.
create_by_user
(
project
,
current_user
)
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?
if
@project
.
saved?
present
@project
,
with:
Entities
::
Project
present
@project
,
with:
Entities
::
Project
else
else
...
...
spec/requests/api/projects_spec.rb
View file @
e078a173
...
@@ -27,7 +27,7 @@ describe Gitlab::API do
...
@@ -27,7 +27,7 @@ describe Gitlab::API do
describe
"POST /projects"
do
describe
"POST /projects"
do
it
"should create new project without code and path"
do
it
"should create new project without code and path"
do
lambda
{
expect
{
name
=
"foo"
name
=
"foo"
post
api
(
"/projects"
,
user
),
{
post
api
(
"/projects"
,
user
),
{
name:
name
name:
name
...
@@ -39,7 +39,41 @@ describe Gitlab::API do
...
@@ -39,7 +39,41 @@ describe Gitlab::API do
}.
should
change
{
Project
.
count
}.
by
(
1
)
}.
should
change
{
Project
.
count
}.
by
(
1
)
end
end
it
"should create new project"
do
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"
name
=
"foo"
path
=
"bar"
path
=
"bar"
code
=
"bazz"
code
=
"bazz"
...
@@ -53,9 +87,10 @@ describe Gitlab::API do
...
@@ -53,9 +87,10 @@ describe Gitlab::API do
json_response
[
"path"
].
should
==
path
json_response
[
"path"
].
should
==
path
json_response
[
"code"
].
should
==
code
json_response
[
"code"
].
should
==
code
}.
should
change
{
Project
.
count
}.
by
(
1
)
}.
should
change
{
Project
.
count
}.
by
(
1
)
end
end
it
"should not create project without name"
do
it
"should not create project without name"
do
lambda
{
expect
{
post
api
(
"/projects"
,
user
)
post
api
(
"/projects"
,
user
)
response
.
status
.
should
==
404
response
.
status
.
should
==
404
}.
should_not
change
{
Project
.
count
}
}.
should_not
change
{
Project
.
count
}
...
...
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