diff options
author | Sean McGivern <sean@gitlab.com> | 2016-10-04 17:46:08 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-10-04 17:46:08 +0100 |
commit | 42cb659726822d500086ce09f712b858228f4caa (patch) | |
tree | aea754187888f682d9bf927242234578627147c1 | |
parent | 355f97f8c321e815b245021488ae4a2a5aa6c2c3 (diff) | |
download | gitlab-ce-42cb659726822d500086ce09f712b858228f4caa.tar.gz |
Update API docs and specs for /projects/visible
-rw-r--r-- | doc/api/projects.md | 4 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 23 |
2 files changed, 24 insertions, 3 deletions
diff --git a/doc/api/projects.md b/doc/api/projects.md index 409e67ea566..2a1054a5337 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -33,6 +33,7 @@ Parameters: - `order_by` (optional) - Return requests ordered by `id`, `name`, `path`, `created_at`, `updated_at` or `last_activity_at` fields. Default is `created_at` - `sort` (optional) - Return requests sorted in `asc` or `desc` order. Default is `desc` - `search` (optional) - Return list of authorized projects according to a search criteria +- `simple` (optional) - When set, return only the ID, URL, name, and path of each project ```json [ @@ -153,7 +154,7 @@ Parameters: ] ``` -Get a list of projects for which the authenticated user can see. +Get a list of projects which the authenticated user can see. ``` GET /projects/visible @@ -166,6 +167,7 @@ Parameters: - `order_by` (optional) - Return requests ordered by `id`, `name`, `path`, `created_at`, `updated_at` or `last_activity_at` fields. Default is `created_at` - `sort` (optional) - Return requests sorted in `asc` or `desc` order. Default is `desc` - `search` (optional) - Return list of authorized projects according to a search criteria +- `simple` (optional) - When set, return only the ID, URL, name, and path of each project ```json [ diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 5bf8b64b84b..fafceb6ecfa 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -178,11 +178,30 @@ describe API::API, api: true do describe 'GET /projects/visible' do let(:public_project) { create(:project, :public) } + before do + public_project + project + project2 + project3 + project4 + end + it 'returns the projects viewable by the user' do - get api('/projects/visible', user3) + get api('/projects/visible', user) + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.map { |project| project['id'] }). + to contain_exactly(public_project.id, project.id, project2.id, project3.id) + end + + it 'shows only public projects when the user only has access to those' do + get api('/projects/visible', user2) + expect(response).to have_http_status(200) expect(json_response).to be_an Array - expect(json_response.map { |project| project['id'] }).to contain_exactly(project.id, project2.id, project4.id) + expect(json_response.map { |project| project['id'] }). + to contain_exactly(public_project.id) end end |