2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
RSpec.describe 'Projects members', :js do
|
2021-03-11 19:13:27 +05:30
|
|
|
include Spec::Support::Helpers::Features::MembersHelpers
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:developer) { create(:user) }
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:group) { create(:group, :public) }
|
|
|
|
let(:project) { create(:project, :public, creator: user, group: group) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:project_invitee) { create(:project_member, project: project, invite_token: '123', invite_email: 'test1@abc.com', user: nil) }
|
|
|
|
let(:group_invitee) { create(:group_member, group: group, invite_token: '123', invite_email: 'test2@abc.com', user: nil) }
|
|
|
|
let(:project_requester) { create(:user) }
|
|
|
|
let(:group_requester) { create(:user) }
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
2018-03-17 18:26:18 +05:30
|
|
|
project.add_developer(developer)
|
2017-08-17 22:00:37 +05:30
|
|
|
group.add_owner(user)
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
context 'when `vue_project_members_list` feature flag is enabled' do
|
|
|
|
context 'with a group invitee' do
|
|
|
|
before do
|
|
|
|
group_invitee
|
|
|
|
visit project_project_members_path(project)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
it 'does not appear in the project members page' do
|
|
|
|
expect(members_table).not_to have_content('test2@abc.com')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
context 'with a group' do
|
|
|
|
it 'shows group and project members by default' do
|
|
|
|
visit project_project_members_path(project)
|
|
|
|
|
|
|
|
expect(members_table).to have_content(developer.name)
|
|
|
|
expect(members_table).to have_content(user.name)
|
|
|
|
expect(members_table).to have_content(group.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows project members only if requested' do
|
|
|
|
visit project_project_members_path(project, with_inherited_permissions: 'exclude')
|
|
|
|
|
|
|
|
expect(members_table).to have_content(developer.name)
|
|
|
|
expect(members_table).not_to have_content(user.name)
|
|
|
|
expect(members_table).not_to have_content(group.name)
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
it 'shows group members only if requested' do
|
|
|
|
visit project_project_members_path(project, with_inherited_permissions: 'only')
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(members_table).not_to have_content(developer.name)
|
|
|
|
expect(members_table).to have_content(user.name)
|
|
|
|
expect(members_table).to have_content(group.name)
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
context 'with a group, a project invitee, and a project requester' do
|
|
|
|
before do
|
|
|
|
group.request_access(group_requester)
|
|
|
|
project.request_access(project_requester)
|
|
|
|
group_invitee
|
|
|
|
project_invitee
|
|
|
|
visit project_project_members_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the group owner' do
|
|
|
|
expect(members_table).to have_content(user.name)
|
|
|
|
expect(members_table).to have_content(group.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the project developer' do
|
|
|
|
expect(members_table).to have_content(developer.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the project invitee' do
|
|
|
|
click_link 'Invited'
|
|
|
|
|
|
|
|
expect(members_table).to have_content('test1@abc.com')
|
|
|
|
expect(members_table).not_to have_content('test2@abc.com')
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
it 'shows the project requester' do
|
|
|
|
click_link 'Access requests'
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(members_table).to have_content(project_requester.name)
|
|
|
|
expect(members_table).not_to have_content(group_requester.name)
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
context 'with a group requester' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(invite_members_group_modal: false)
|
|
|
|
group.request_access(group_requester)
|
|
|
|
visit project_project_members_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not appear in the project members page' do
|
|
|
|
expect(page).not_to have_link('Access requests')
|
|
|
|
expect(members_table).not_to have_content(group_requester.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'showing status of members' do
|
|
|
|
it 'shows the status' do
|
|
|
|
create(:user_status, user: user, emoji: 'smirk', message: 'Authoring this object')
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
visit project_project_members_path(project)
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(first_row).to have_selector('gl-emoji[data-name="smirk"]')
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
context 'when `vue_project_members_list` feature flag is disabled' do
|
2017-08-17 22:00:37 +05:30
|
|
|
before do
|
2021-03-11 19:13:27 +05:30
|
|
|
stub_feature_flags(vue_project_members_list: false)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
context 'with a group invitee' do
|
|
|
|
before do
|
|
|
|
group_invitee
|
|
|
|
visit project_project_members_path(project)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
it 'does not appear in the project members page' do
|
|
|
|
page.within first('.content-list') do
|
|
|
|
expect(page).not_to have_content('test2@abc.com')
|
|
|
|
end
|
2021-03-08 18:12:59 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
context 'with a group' do
|
|
|
|
it 'shows group and project members by default' do
|
|
|
|
visit project_project_members_path(project)
|
2021-03-08 18:12:59 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
page.within first('.content-list') do
|
|
|
|
expect(page).to have_content(developer.name)
|
|
|
|
|
|
|
|
expect(page).to have_content(user.name)
|
|
|
|
expect(page).to have_content(group.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows project members only if requested' do
|
|
|
|
visit project_project_members_path(project, with_inherited_permissions: 'exclude')
|
|
|
|
|
|
|
|
page.within first('.content-list') do
|
|
|
|
expect(page).to have_content(developer.name)
|
|
|
|
|
|
|
|
expect(page).not_to have_content(user.name)
|
|
|
|
expect(page).not_to have_content(group.name)
|
|
|
|
end
|
2021-03-08 18:12:59 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
it 'shows group members only if requested' do
|
|
|
|
visit project_project_members_path(project, with_inherited_permissions: 'only')
|
2021-03-08 18:12:59 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
page.within first('.content-list') do
|
|
|
|
expect(page).not_to have_content(developer.name)
|
|
|
|
|
|
|
|
expect(page).to have_content(user.name)
|
|
|
|
expect(page).to have_content(group.name)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
context 'with a group, a project invitee, and a project requester' do
|
|
|
|
before do
|
|
|
|
group.request_access(group_requester)
|
|
|
|
project.request_access(project_requester)
|
|
|
|
group_invitee
|
|
|
|
project_invitee
|
|
|
|
visit project_project_members_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the group owner' do
|
|
|
|
page.within first('.content-list') do
|
|
|
|
# Group owner
|
|
|
|
expect(page).to have_content(user.name)
|
|
|
|
expect(page).to have_content(group.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the project developer' do
|
|
|
|
page.within first('.content-list') do
|
|
|
|
# Project developer
|
|
|
|
expect(page).to have_content(developer.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the project invitee' do
|
|
|
|
click_link 'Invited'
|
|
|
|
|
|
|
|
page.within first('.content-list') do
|
|
|
|
expect(page).to have_content('test1@abc.com')
|
|
|
|
expect(page).not_to have_content('test2@abc.com')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the project requester' do
|
|
|
|
click_link 'Access requests'
|
|
|
|
|
|
|
|
page.within first('.content-list') do
|
|
|
|
expect(page).to have_content(project_requester.name)
|
|
|
|
expect(page).not_to have_content(group_requester.name)
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
context 'with a group requester' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(invite_members_group_modal: false)
|
|
|
|
group.request_access(group_requester)
|
|
|
|
visit project_project_members_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not appear in the project members page' do
|
|
|
|
expect(page).not_to have_link('Access requests')
|
|
|
|
page.within first('.content-list') do
|
|
|
|
expect(page).not_to have_content(group_requester.name)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
context 'showing status of members' do
|
|
|
|
it_behaves_like 'showing user status' do
|
|
|
|
let(:user_with_status) { developer }
|
2018-11-18 11:00:15 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
subject { visit project_project_members_path(project) }
|
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|