Update API docs and specs for /projects/visible

This commit is contained in:
Sean McGivern 2016-10-04 17:46:08 +01:00
parent 355f97f8c3
commit 42cb659726
2 changed files with 24 additions and 3 deletions

View File

@ -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
[

View File

@ -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(project.id, project2.id, project4.id)
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(public_project.id)
end
end