Commit 42cb6597 authored by Sean McGivern's avatar Sean McGivern

Update API docs and specs for /projects/visible

parent 355f97f8
......@@ -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
[
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment