diff options
author | Nick Thomas <nick@gitlab.com> | 2019-01-18 18:36:58 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-01-18 18:36:58 +0300 |
commit | 41ae26d9eacbe53213d0786589003b5119d383c4 (patch) | |
tree | 962004e553a0449546e5c62884a37e9c1c9734c1 /spec/requests/api/projects_spec.rb | |
parent | 5e01cf72249725cb6e0c8aa3d28325d9b4942566 (diff) | |
parent | ab94a5a53712740df3836413bf26e4856b5f7cb2 (diff) |
Merge branch 'api-nested-group-permission' into 'master'
Return the maximum group access level in the projects API
Closes #43684
See merge request gitlab-org/gitlab-ce!24403
Diffstat (limited to 'spec/requests/api/projects_spec.rb')
-rw-r--r-- | spec/requests/api/projects_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index a01b494f615..7248908b494 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -1147,6 +1147,40 @@ describe API::Projects do .to eq(Gitlab::Access::OWNER) end end + + context 'nested group project', :nested_groups do + let(:group) { create(:group) } + let(:nested_group) { create(:group, parent: group) } + let(:project2) { create(:project, group: nested_group) } + + before do + project2.group.parent.add_owner(user) + end + + it 'sets group access and return 200' do + get api("/projects/#{project2.id}", user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response['permissions']['project_access']).to be_nil + expect(json_response['permissions']['group_access']['access_level']) + .to eq(Gitlab::Access::OWNER) + end + + context 'with various access levels across nested groups' do + before do + project2.group.add_maintainer(user) + end + + it 'sets the maximum group access and return 200' do + get api("/projects/#{project2.id}", user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response['permissions']['project_access']).to be_nil + expect(json_response['permissions']['group_access']['access_level']) + .to eq(Gitlab::Access::OWNER) + end + end + end end end end |