Commit 3c059697 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #4538 from amacarthur/public-project-api2

enhance project creation apis to allow setting of public attribute
parents 17b56573 ace5c54a
...@@ -189,6 +189,7 @@ Parameters: ...@@ -189,6 +189,7 @@ Parameters:
+ `merge_requests_enabled` (optional) + `merge_requests_enabled` (optional)
+ `wiki_enabled` (optional) + `wiki_enabled` (optional)
+ `snippets_enabled` (optional) + `snippets_enabled` (optional)
+ `public` (optional)
**Project access levels** **Project access levels**
...@@ -221,6 +222,7 @@ Parameters: ...@@ -221,6 +222,7 @@ Parameters:
+ `merge_requests_enabled` (optional) + `merge_requests_enabled` (optional)
+ `wiki_enabled` (optional) + `wiki_enabled` (optional)
+ `snippets_enabled` (optional) + `snippets_enabled` (optional)
+ `public` (optional)
......
...@@ -36,7 +36,7 @@ module API ...@@ -36,7 +36,7 @@ module API
expose :owner, using: Entities::UserBasic expose :owner, using: Entities::UserBasic
expose :name, :name_with_namespace expose :name, :name_with_namespace
expose :path, :path_with_namespace expose :path, :path_with_namespace
expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :snippets_enabled, :created_at, :last_activity_at expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :snippets_enabled, :created_at, :last_activity_at, :public
expose :namespace expose :namespace
expose :forked_from_project, using: Entities::ForkedFromProject, :if => lambda{ | project, options | project.forked? } expose :forked_from_project, using: Entities::ForkedFromProject, :if => lambda{ | project, options | project.forked? }
end end
......
...@@ -67,6 +67,7 @@ module API ...@@ -67,6 +67,7 @@ module API
# wiki_enabled (optional) # wiki_enabled (optional)
# snippets_enabled (optional) # snippets_enabled (optional)
# namespace_id (optional) - defaults to user namespace # namespace_id (optional) - defaults to user namespace
# public (optional) - false by default
# Example Request # Example Request
# POST /projects # POST /projects
post do post do
...@@ -79,7 +80,8 @@ module API ...@@ -79,7 +80,8 @@ module API
:merge_requests_enabled, :merge_requests_enabled,
:wiki_enabled, :wiki_enabled,
:snippets_enabled, :snippets_enabled,
:namespace_id] :namespace_id,
:public]
@project = ::Projects::CreateContext.new(current_user, attrs).execute @project = ::Projects::CreateContext.new(current_user, attrs).execute
if @project.saved? if @project.saved?
present @project, with: Entities::Project present @project, with: Entities::Project
...@@ -103,6 +105,7 @@ module API ...@@ -103,6 +105,7 @@ module API
# merge_requests_enabled (optional) # merge_requests_enabled (optional)
# wiki_enabled (optional) # wiki_enabled (optional)
# snippets_enabled (optional) # snippets_enabled (optional)
# public (optional)
# Example Request # Example Request
# POST /projects/user/:user_id # POST /projects/user/:user_id
post "user/:user_id" do post "user/:user_id" do
...@@ -115,7 +118,8 @@ module API ...@@ -115,7 +118,8 @@ module API
:wall_enabled, :wall_enabled,
:merge_requests_enabled, :merge_requests_enabled,
:wiki_enabled, :wiki_enabled,
:snippets_enabled] :snippets_enabled,
:public]
@project = ::Projects::CreateContext.new(user, attrs).execute @project = ::Projects::CreateContext.new(user, attrs).execute
if @project.saved? if @project.saved?
present @project, with: Entities::Project present @project, with: Entities::Project
......
...@@ -104,6 +104,21 @@ describe API::API do ...@@ -104,6 +104,21 @@ describe API::API do
json_response[k.to_s].should == v json_response[k.to_s].should == v
end end
end end
it "should set a project as public" do
project = attributes_for(:project, { public: true })
post api("/projects", user), project
json_response['public'].should be_true
end
it "should set a project as private" do
project = attributes_for(:project, { public: false })
post api("/projects", user), project
json_response['public'].should be_false
end
end end
describe "POST /projects/user/:id" do describe "POST /projects/user/:id" do
...@@ -144,6 +159,21 @@ describe API::API do ...@@ -144,6 +159,21 @@ describe API::API do
json_response[k.to_s].should == v json_response[k.to_s].should == v
end end
end end
it "should set a project as public" do
project = attributes_for(:project, { public: true })
post api("/projects/user/#{user.id}", admin), project
json_response['public'].should be_true
end
it "should set a project as private" do
project = attributes_for(:project, { public: false })
post api("/projects/user/#{user.id}", admin), project
json_response['public'].should be_false
end
end end
describe "GET /projects/:id" do describe "GET /projects/:id" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment