diff options
author | Sean McGivern <sean@gitlab.com> | 2016-10-04 19:46:08 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-10-04 19:46:08 +0300 |
commit | 42cb659726822d500086ce09f712b858228f4caa (patch) | |
tree | aea754187888f682d9bf927242234578627147c1 /spec/requests/api/projects_spec.rb | |
parent | 355f97f8c321e815b245021488ae4a2a5aa6c2c3 (diff) |
Update API docs and specs for /projects/visible
Diffstat (limited to 'spec/requests/api/projects_spec.rb')
-rw-r--r-- | spec/requests/api/projects_spec.rb | 23 |
1 files changed, 21 insertions, 2 deletions
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 |