mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-20 10:06:04 +10:00
Merge branch 'feature/api_projects_all' of /home/git/repositories/gitlab/gitlabhq
This commit is contained in:
+17
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
### List projects
|
||||
|
||||
Get a list of projects owned by the authenticated user.
|
||||
Get a list of projects accessible by the authenticated user.
|
||||
|
||||
```
|
||||
GET /projects
|
||||
@@ -82,6 +82,22 @@ GET /projects
|
||||
```
|
||||
|
||||
|
||||
#### List owned projects
|
||||
|
||||
Get a list of projects owned by the authenticated user.
|
||||
|
||||
```
|
||||
GET /projects/owned
|
||||
```
|
||||
|
||||
#### List ALL projects
|
||||
|
||||
Get a list of all GitLab projects (admin only).
|
||||
|
||||
```
|
||||
GET /projects/all
|
||||
```
|
||||
|
||||
### Get single project
|
||||
|
||||
Get a specific project, identified by project ID or NAMESPACE/PROJECT_NAME , which is owned by the authentication user.
|
||||
|
||||
@@ -31,6 +31,16 @@ module API
|
||||
present @projects, with: Entities::Project
|
||||
end
|
||||
|
||||
# Get all projects for admin user
|
||||
#
|
||||
# Example Request:
|
||||
# GET /projects/all
|
||||
get '/all' do
|
||||
authenticated_as_admin!
|
||||
@projects = paginate Project
|
||||
present @projects, with: Entities::Project
|
||||
end
|
||||
|
||||
# Get a single project
|
||||
#
|
||||
# Parameters:
|
||||
|
||||
@@ -36,6 +36,32 @@ describe API::API do
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /projects/all" do
|
||||
context "when unauthenticated" do
|
||||
it "should return authentication error" do
|
||||
get api("/projects/all")
|
||||
response.status.should == 401
|
||||
end
|
||||
end
|
||||
|
||||
context "when authenticated as regular user" do
|
||||
it "should return authentication error" do
|
||||
get api("/projects/all", user)
|
||||
response.status.should == 403
|
||||
end
|
||||
end
|
||||
|
||||
context "when authenticated as admin" do
|
||||
it "should return an array of all projects" do
|
||||
get api("/projects/all", admin)
|
||||
response.status.should == 200
|
||||
json_response.should be_an Array
|
||||
json_response.first['name'].should == project.name
|
||||
json_response.first['owner']['email'].should == user.email
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /projects" do
|
||||
context "maximum number of projects reached" do
|
||||
before do
|
||||
|
||||
Reference in New Issue
Block a user