debian-mirror-gitlab/spec/features/groups/members/leave_group_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

89 lines
2.3 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'Groups > Members > Leave group' do
2021-01-29 00:20:46 +05:30
include Spec::Support::Helpers::Features::MembersHelpers
2022-07-23 23:45:48 +05:30
include Spec::Support::Helpers::ModalHelpers
2021-01-29 00:20:46 +05:30
2017-09-10 17:25:29 +05:30
let(:user) { create(:user) }
let(:other_user) { create(:user) }
let(:group) { create(:group) }
2018-11-08 19:23:39 +05:30
before do
2021-01-29 00:20:46 +05:30
sign_in(user)
2017-09-10 17:25:29 +05:30
end
2018-11-08 19:23:39 +05:30
it 'guest leaves the group' do
2017-09-10 17:25:29 +05:30
group.add_guest(user)
group.add_owner(other_user)
visit group_path(group)
click_link 'Leave group'
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(dashboard_groups_path, ignore_query: true)
2017-09-10 17:25:29 +05:30
expect(page).to have_content left_group_message(group)
expect(group.users).not_to include(user)
end
2019-07-31 22:56:46 +05:30
it 'guest leaves the group by url param', :js do
group.add_guest(user)
group.add_owner(other_user)
visit group_path(group, leave: 1)
2022-07-23 23:45:48 +05:30
accept_gl_confirm(button_text: 'Leave group')
2019-07-31 22:56:46 +05:30
2020-06-23 00:09:42 +05:30
wait_for_all_requests
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(dashboard_groups_path, ignore_query: true)
2019-07-31 22:56:46 +05:30
expect(group.users).not_to include(user)
end
2018-11-08 19:23:39 +05:30
it 'guest leaves the group as last member' do
2017-09-10 17:25:29 +05:30
group.add_guest(user)
visit group_path(group)
click_link 'Leave group'
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(dashboard_groups_path, ignore_query: true)
2017-09-10 17:25:29 +05:30
expect(page).to have_content left_group_message(group)
expect(group.users).not_to include(user)
end
2019-07-31 22:56:46 +05:30
it 'owner leaves the group if they are not the last owner' do
2017-09-10 17:25:29 +05:30
group.add_owner(user)
group.add_owner(other_user)
visit group_path(group)
click_link 'Leave group'
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(dashboard_groups_path, ignore_query: true)
2017-09-10 17:25:29 +05:30
expect(page).to have_content left_group_message(group)
expect(group.users).not_to include(user)
end
2021-01-29 00:20:46 +05:30
it 'owner can not leave the group if they are the last owner', :js do
2017-09-10 17:25:29 +05:30
group.add_owner(user)
visit group_path(group)
expect(page).not_to have_content 'Leave group'
visit group_group_members_path(group)
2021-01-29 00:20:46 +05:30
expect(members_table).not_to have_selector 'button[title="Leave"]'
2017-09-10 17:25:29 +05:30
end
2019-07-31 22:56:46 +05:30
it 'owner can not leave the group by url param if they are the last owner', :js do
group.add_owner(user)
visit group_path(group, leave: 1)
2022-04-04 11:22:00 +05:30
expect(find('[data-testid="alert-danger"]')).to have_content 'You do not have permission to leave this group'
2019-07-31 22:56:46 +05:30
end
2017-09-10 17:25:29 +05:30
def left_group_message(group)
"You left the \"#{group.name}\""
end
end