Update API docs and specs for /projects/visible
This commit is contained in:
parent
355f97f8c3
commit
42cb659726
|
@ -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`
|
- `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`
|
- `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
|
- `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
|
```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
|
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`
|
- `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`
|
- `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
|
- `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
|
```json
|
||||||
[
|
[
|
||||||
|
|
|
@ -178,11 +178,30 @@ describe API::API, api: true do
|
||||||
describe 'GET /projects/visible' do
|
describe 'GET /projects/visible' do
|
||||||
let(:public_project) { create(:project, :public) }
|
let(:public_project) { create(:project, :public) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
public_project
|
||||||
|
project
|
||||||
|
project2
|
||||||
|
project3
|
||||||
|
project4
|
||||||
|
end
|
||||||
|
|
||||||
it 'returns the projects viewable by the user' do
|
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(response).to have_http_status(200)
|
||||||
expect(json_response).to be_an Array
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue