diff options
Diffstat (limited to 'spec/controllers/groups/group_members_controller_spec.rb')
-rw-r--r-- | spec/controllers/groups/group_members_controller_spec.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/spec/controllers/groups/group_members_controller_spec.rb b/spec/controllers/groups/group_members_controller_spec.rb index 25d32436d58..c6fd184ede0 100644 --- a/spec/controllers/groups/group_members_controller_spec.rb +++ b/spec/controllers/groups/group_members_controller_spec.rb @@ -305,11 +305,37 @@ RSpec.describe Groups::GroupMembersController do group.add_owner(user) end - it 'cannot removes himself from the group' do + it 'cannot remove user from the group' do delete :leave, params: { group_id: group } expect(response).to have_gitlab_http_status(:forbidden) end + + context 'and there is a group project bot owner' do + before do + create(:group_member, :owner, source: group, user: create(:user, :project_bot)) + end + + it 'cannot remove user from the group' do + delete :leave, params: { group_id: group } + + expect(response).to have_gitlab_http_status(:forbidden) + end + end + + context 'and there is another owner' do + before do + create(:group_member, :owner, source: group) + end + + it 'removes user from members', :aggregate_failures do + delete :leave, params: { group_id: group } + + expect(controller).to set_flash.to "You left the \"#{group.name}\" group." + expect(response).to redirect_to(dashboard_groups_path) + expect(group.users).not_to include user + end + end end context 'and is a requester' do |