diff options
author | Rémy Coutable <remy@rymai.me> | 2016-10-07 12:54:44 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-10-07 12:54:44 +0300 |
commit | 1be151621721d9e89c4c6514b8523e999e5e0fed (patch) | |
tree | 1c9d81886e94b43bd487529966c82e5f40361f5e /spec/requests/api/projects_spec.rb | |
parent | b58ea12aa9b7ba9f3a8bcdfce32cb775ba05999a (diff) | |
parent | 7623ab0cf4f966ee809845341842d0af5ce69061 (diff) |
Merge branch 'ben.boeckel/gitlab-ce-api-visible-projects' into 'master'
Add visible projects API
## What does this MR do?
Add a new `/projects/visible` API endpoint. Originally created by @ben.boeckel in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5970.
## Are there points in the code the reviewer needs to double check?
Does the API make sense?
## Why was this MR needed?
The `/projects` endpoint only returned projects the user was explicitly a member of.
Closes #19361, #3119.
See merge request !6681
Diffstat (limited to 'spec/requests/api/projects_spec.rb')
-rw-r--r-- | spec/requests/api/projects_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 861eb12b94c..5f19638b460 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -175,6 +175,36 @@ describe API::API, api: true do end end + 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', 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(public_project.id) + end + end + describe 'GET /projects/starred' do let(:public_project) { create(:project, :public) } |