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

143 lines
3.4 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'Groups > Members > Manage members' do
2017-08-17 22:00:37 +05:30
include Select2Helper
2021-01-29 00:20:46 +05:30
include Spec::Support::Helpers::Features::MembersHelpers
2017-08-17 22:00:37 +05:30
let(:user1) { create(:user, name: 'John Doe') }
let(:user2) { create(:user, name: 'Mary Jane') }
let(:group) { create(:group) }
2018-11-08 19:23:39 +05:30
before do
2017-09-10 17:25:29 +05:30
sign_in(user1)
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
it 'update user to owner level', :js do
2017-08-17 22:00:37 +05:30
group.add_owner(user1)
group.add_developer(user2)
visit group_group_members_path(group)
page.within(second_row) do
click_button('Developer')
2021-01-29 00:20:46 +05:30
click_button('Owner')
2017-08-17 22:00:37 +05:30
expect(page).to have_button('Owner')
end
end
2018-11-08 19:23:39 +05:30
it 'add user to group', :js do
2017-08-17 22:00:37 +05:30
group.add_owner(user1)
visit group_group_members_path(group)
add_user(user2.id, 'Reporter')
page.within(second_row) do
expect(page).to have_content(user2.name)
expect(page).to have_button('Reporter')
end
end
2018-11-08 19:23:39 +05:30
it 'do not disclose email addresses', :js do
2018-03-17 18:26:18 +05:30
group.add_owner(user1)
create(:user, email: 'undisclosed_email@gitlab.com', name: "Jane 'invisible' Doe")
visit group_group_members_path(group)
find('.select2-container').click
select_input = find('.select2-input')
select_input.send_keys('@gitlab.com')
wait_for_requests
expect(page).to have_content('No matches found')
select_input.native.clear
select_input.send_keys('undisclosed_email@gitlab.com')
wait_for_requests
expect(page).to have_content("Jane 'invisible' Doe")
end
2018-11-08 19:23:39 +05:30
it 'remove user from group', :js do
2017-09-10 17:25:29 +05:30
group.add_owner(user1)
group.add_developer(user2)
visit group_group_members_path(group)
2020-07-28 23:09:34 +05:30
# Open modal
2021-01-29 00:20:46 +05:30
page.within(second_row) do
click_button 'Remove member'
end
2020-07-28 23:09:34 +05:30
2021-01-29 00:20:46 +05:30
page.within('[role="dialog"]') do
expect(page).to have_unchecked_field 'Also unassign this user from related issues and merge requests'
click_button('Remove member')
end
2018-03-17 18:26:18 +05:30
wait_for_requests
2017-09-10 17:25:29 +05:30
expect(page).not_to have_content(user2.name)
expect(group.users).not_to include(user2)
end
2018-11-08 19:23:39 +05:30
it 'add yourself to group when already an owner', :js do
2017-08-17 22:00:37 +05:30
group.add_owner(user1)
visit group_group_members_path(group)
add_user(user1.id, 'Reporter')
page.within(first_row) do
expect(page).to have_content(user1.name)
expect(page).to have_content('Owner')
end
end
2018-11-08 19:23:39 +05:30
it 'invite user to group', :js do
2017-08-17 22:00:37 +05:30
group.add_owner(user1)
visit group_group_members_path(group)
add_user('test@example.com', 'Reporter')
2021-01-29 00:20:46 +05:30
expect(page).to have_link 'Invited'
click_link 'Invited'
2019-10-12 21:52:04 +05:30
2021-01-29 00:20:46 +05:30
page.within(members_table) do
2017-08-17 22:00:37 +05:30
expect(page).to have_content('test@example.com')
expect(page).to have_content('Invited')
expect(page).to have_button('Reporter')
end
end
2021-01-29 00:20:46 +05:30
it 'guest can not manage other users', :js do
2017-09-10 17:25:29 +05:30
group.add_guest(user1)
group.add_developer(user2)
visit group_group_members_path(group)
2020-03-13 15:44:24 +05:30
expect(page).not_to have_selector '.invite-users-form'
expect(page).not_to have_selector '.invite-group-form'
2017-09-10 17:25:29 +05:30
page.within(second_row) do
# Can not modify user2 role
expect(page).not_to have_button 'Developer'
# Can not remove user2
2021-01-29 00:20:46 +05:30
expect(page).not_to have_selector 'button[title="Remove member"]'
2017-09-10 17:25:29 +05:30
end
end
2017-08-17 22:00:37 +05:30
def add_user(id, role)
2020-03-13 15:44:24 +05:30
page.within ".invite-users-form" do
2017-08-17 22:00:37 +05:30
select2(id, from: "#user_ids", multiple: true)
select(role, from: "access_level")
2020-03-13 15:44:24 +05:30
click_button "Invite"
2017-08-17 22:00:37 +05:30
end
end
end