debian-mirror-gitlab/spec/features/projects/members/list_spec.rb

122 lines
3 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 'Project members list' do
2017-08-17 22:00:37 +05:30
include Select2Helper
2019-02-15 15:39:39 +05:30
include Spec::Support::Helpers::Features::ListRowsHelpers
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) }
let(:project) { create(:project, namespace: 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
group.add_owner(user1)
end
2018-11-08 19:23:39 +05:30
it 'show members from project and group' do
2017-08-17 22:00:37 +05:30
project.add_developer(user2)
visit_members_page
expect(first_row.text).to include(user1.name)
expect(second_row.text).to include(user2.name)
end
2018-11-08 19:23:39 +05:30
it 'show user once if member of both group and project' do
2017-08-17 22:00:37 +05:30
project.add_developer(user1)
visit_members_page
expect(first_row.text).to include(user1.name)
expect(second_row).to be_blank
end
2020-05-24 23:13:21 +05:30
it 'update user access level', :js do
2017-08-17 22:00:37 +05:30
project.add_developer(user2)
visit_members_page
page.within(second_row) do
click_button('Developer')
click_link('Reporter')
expect(page).to have_button('Reporter')
end
end
2018-11-08 19:23:39 +05:30
it 'add user to project', :js do
2017-08-17 22:00:37 +05:30
visit_members_page
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 'remove user from project', :js do
2018-03-17 18:26:18 +05:30
other_user = create(:user)
project.add_developer(other_user)
visit_members_page
2020-07-28 23:09:34 +05:30
# Open modal
2020-10-24 23:57:45 +05:30
find(:css, 'li.project_member', text: other_user.name).find(:css, 'button.btn-danger').click
2020-07-28 23:09:34 +05:30
expect(page).to have_unchecked_field 'Also unassign this user from related issues and merge requests'
click_on('Remove member')
2018-03-17 18:26:18 +05:30
wait_for_requests
expect(page).not_to have_content(other_user.name)
expect(project.users).not_to include(other_user)
end
2018-11-08 19:23:39 +05:30
it 'invite user to project', :js do
2017-08-17 22:00:37 +05:30
visit_members_page
add_user('test@example.com', 'Reporter')
page.within(second_row) do
expect(page).to have_content('test@example.com')
expect(page).to have_content('Invited')
expect(page).to have_button('Reporter')
end
end
2020-05-24 23:13:21 +05:30
context 'project bots' do
let(:project_bot) { create(:user, :project_bot, name: 'project_bot') }
before do
project.add_maintainer(project_bot)
end
it 'does not show form used to change roles and "Expiration date" or the remove user button' do
project_member = project.project_members.find_by(user_id: project_bot.id)
visit_members_page
expect(page).not_to have_selector("#edit_project_member_#{project_member.id}")
expect(page).not_to have_selector("#project_member_#{project_member.id} .btn-remove")
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")
end
2020-03-13 15:44:24 +05:30
click_button "Invite"
2017-08-17 22:00:37 +05:30
end
def visit_members_page
2020-06-23 00:09:42 +05:30
visit project_project_members_path(project)
2017-08-17 22:00:37 +05:30
end
end