From a09fc160d02f232e9819c7459a9ff91a4e990bf3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 18 Nov 2013 14:15:59 +0200 Subject: Add project.all for API if admin Signed-off-by: Dmitriy Zaporozhets --- lib/api/projects.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 42560572046..b927e63f4a4 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -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: -- cgit v1.2.1 From ba169cc52d42425525921464070a513097a003ff Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 18 Nov 2013 16:42:56 +0200 Subject: API: projects/all tests Signed-off-by: Dmitriy Zaporozhets --- spec/requests/api/projects_spec.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 2ae186b967a..e4cef6c587c 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -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 -- cgit v1.2.1 From 11931bfb9c683ec615d3c4935976b7f70262f291 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 18 Nov 2013 16:49:29 +0200 Subject: update projects api docs Signed-off-by: Dmitriy Zaporozhets --- doc/api/projects.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/api/projects.md b/doc/api/projects.md index d4d883e54ec..6179d857677 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -2,7 +2,7 @@ ### List projects -Get a list of projects owned by the authenticated user. +Get a list of projects acessed 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. -- cgit v1.2.1 From 434d276dba22924dbcbd903d4fea0d20c409ed98 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 18 Nov 2013 19:53:10 +0200 Subject: better wording for api doc Signed-off-by: Dmitriy Zaporozhets --- doc/api/projects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/projects.md b/doc/api/projects.md index 6179d857677..9b5d62ac832 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -2,7 +2,7 @@ ### List projects -Get a list of projects acessed by the authenticated user. +Get a list of projects accessible by the authenticated user. ``` GET /projects -- cgit v1.2.1