diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/controllers/groups/group_members_controller_spec.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/controllers/groups/group_members_controller_spec.rb')
-rw-r--r-- | spec/controllers/groups/group_members_controller_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/controllers/groups/group_members_controller_spec.rb b/spec/controllers/groups/group_members_controller_spec.rb index a3659ae9163..4e5dc01f466 100644 --- a/spec/controllers/groups/group_members_controller_spec.rb +++ b/spec/controllers/groups/group_members_controller_spec.rb @@ -342,6 +342,41 @@ RSpec.describe Groups::GroupMembersController do end end + context 'with owners from a parent' do + context 'when top-level group' do + context 'with group sharing' do + let!(:subgroup) { create(:group, parent: group) } + + before do + create(:group_group_link, :owner, shared_group: group, shared_with_group: subgroup) + create(:group_member, :owner, group: subgroup) + end + + it 'does not allow removal of last direct group owner' do + delete :leave, params: { group_id: group } + + expect(response).to have_gitlab_http_status(:forbidden) + end + end + end + + context 'when subgroup' do + let!(:subgroup) { create(:group, parent: group) } + + before do + subgroup.add_owner(user) + end + + it 'allows removal of last direct group owner', :aggregate_failures do + delete :leave, params: { group_id: subgroup } + + expect(controller).to set_flash.to "You left the \"#{subgroup.human_name}\" group." + expect(response).to redirect_to(dashboard_groups_path) + expect(subgroup.users).not_to include user + end + end + end + context 'and there is another owner' do before do create(:group_member, :owner, source: group) |