debian-mirror-gitlab/spec/features/groups/group_settings_spec.rb

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

336 lines
10 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'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Edit group settings', feature_category: :subgroups do
2023-06-20 00:43:36 +05:30
include Spec::Support::Helpers::ModalHelpers
2018-11-08 19:23:39 +05:30
let(:user) { create(:user) }
let(:group) { create(:group, path: 'foo') }
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
before do
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
describe 'when the group path is changed' do
let(:new_group_path) { 'bar' }
let(:old_group_full_path) { "/#{group.path}" }
let(:new_group_full_path) { "/#{new_group_path}" }
2018-11-08 19:23:39 +05:30
it 'the group is accessible via the new path' do
2017-08-17 22:00:37 +05:30
update_path(new_group_path)
visit new_group_full_path
2020-01-01 13:55:28 +05:30
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(new_group_full_path, ignore_query: true)
2019-03-02 22:35:43 +05:30
expect(find('h1.home-panel-title')).to have_content(group.name)
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
it 'the old group path redirects to the new path' do
2017-08-17 22:00:37 +05:30
update_path(new_group_path)
visit old_group_full_path
2020-01-01 13:55:28 +05:30
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(new_group_full_path, ignore_query: true)
2019-03-02 22:35:43 +05:30
expect(find('h1.home-panel-title')).to have_content(group.name)
2017-08-17 22:00:37 +05:30
end
context 'with a subgroup' do
2018-11-08 19:23:39 +05:30
let!(:subgroup) { create(:group, parent: group, path: 'subgroup') }
let(:old_subgroup_full_path) { "/#{group.path}/#{subgroup.path}" }
let(:new_subgroup_full_path) { "/#{new_group_path}/#{subgroup.path}" }
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
it 'the subgroup is accessible via the new path' do
2017-08-17 22:00:37 +05:30
update_path(new_group_path)
visit new_subgroup_full_path
2020-01-01 13:55:28 +05:30
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(new_subgroup_full_path, ignore_query: true)
2019-03-02 22:35:43 +05:30
expect(find('h1.home-panel-title')).to have_content(subgroup.name)
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
it 'the old subgroup path redirects to the new path' do
2017-08-17 22:00:37 +05:30
update_path(new_group_path)
visit old_subgroup_full_path
2020-01-01 13:55:28 +05:30
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(new_subgroup_full_path, ignore_query: true)
2019-03-02 22:35:43 +05:30
expect(find('h1.home-panel-title')).to have_content(subgroup.name)
2017-08-17 22:00:37 +05:30
end
end
context 'with a project' do
2018-11-08 19:23:39 +05:30
let!(:project) { create(:project, group: group) }
let(:old_project_full_path) { "/#{group.path}/#{project.path}" }
let(:new_project_full_path) { "/#{new_group_path}/#{project.path}" }
2017-09-10 17:25:29 +05:30
before(:context) do
TestEnv.clean_test_path
end
2018-03-17 18:26:18 +05:30
after do
2017-09-10 17:25:29 +05:30
TestEnv.clean_test_path
end
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
it 'the project is accessible via the new path' do
2017-08-17 22:00:37 +05:30
update_path(new_group_path)
visit new_project_full_path
2020-01-01 13:55:28 +05:30
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(new_project_full_path, ignore_query: true)
2023-07-09 08:55:56 +05:30
expect(find('.breadcrumbs')).to have_content(project.name)
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
it 'the old project path redirects to the new path' do
2017-08-17 22:00:37 +05:30
update_path(new_group_path)
visit old_project_full_path
2020-01-01 13:55:28 +05:30
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(new_project_full_path, ignore_query: true)
2023-07-09 08:55:56 +05:30
expect(find('.breadcrumbs')).to have_content(project.name)
2017-08-17 22:00:37 +05:30
end
end
end
2018-05-09 12:01:36 +05:30
2019-07-07 11:18:12 +05:30
describe 'project creation level menu' do
it 'shows the selection menu' do
visit edit_group_path(group)
2022-08-13 15:12:31 +05:30
expect(page).to have_content('Roles allowed to create projects')
2019-07-07 11:18:12 +05:30
end
end
2019-10-12 21:52:04 +05:30
describe 'subgroup creation level menu' do
it 'shows the selection menu' do
visit edit_group_path(group)
2022-08-13 15:12:31 +05:30
expect(page).to have_content('Roles allowed to create subgroups')
2019-10-12 21:52:04 +05:30
end
end
2018-05-09 12:01:36 +05:30
describe 'edit group avatar' do
before do
visit edit_group_path(group)
attach_file(:group_avatar, Rails.root.join('spec', 'fixtures', 'banana_sample.gif'))
2020-01-01 13:55:28 +05:30
expect { save_general_group }.to change { group.reload.avatar? }.to(true)
2018-05-09 12:01:36 +05:30
end
it 'uploads new group avatar' do
expect(group.avatar).to be_instance_of AvatarUploader
expect(group.avatar.url).to eq "/uploads/-/system/group/avatar/#{group.id}/banana_sample.gif"
expect(page).to have_link('Remove avatar')
end
it 'removes group avatar' do
expect { click_link 'Remove avatar' }.to change { group.reload.avatar? }.to(false)
expect(page).not_to have_link('Remove avatar')
end
end
2017-08-17 22:00:37 +05:30
2018-12-05 23:21:45 +05:30
describe 'edit group path' do
it 'has a root URL label for top-level group' do
visit edit_group_path(group)
expect(find(:css, '.group-root-path').text).to eq(root_url)
end
2019-10-12 21:52:04 +05:30
it 'has a parent group URL label for a subgroup group' do
2018-12-05 23:21:45 +05:30
subgroup = create(:group, parent: group)
visit edit_group_path(subgroup)
expect(find(:css, '.group-root-path').text).to eq(group_url(subgroup.parent) + '/')
end
end
2022-04-04 11:22:00 +05:30
describe 'transfer group', :js do
let(:namespace_select) { page.find('[data-testid="transfer-group-namespace-select"]') }
let(:confirm_modal) { page.find('[data-testid="confirm-danger-modal"]') }
shared_examples 'can transfer the group' do
before do
selected_group.add_owner(user)
end
2023-05-27 22:25:52 +05:30
it 'can successfully transfer the group' do
2023-06-20 00:43:36 +05:30
selected_group_path = selected_group.path
2022-04-04 11:22:00 +05:30
visit edit_group_path(selected_group)
2023-01-13 00:05:48 +05:30
page.within('[data-testid="transfer-locations-dropdown"]') do
click_button _('Select parent group')
2023-06-20 00:43:36 +05:30
fill_in _('Search'), with: target_group&.name || ''
2023-01-13 00:05:48 +05:30
wait_for_requests
2023-06-20 00:43:36 +05:30
click_button(target_group&.name || 'No parent group')
2022-04-04 11:22:00 +05:30
end
2023-01-13 00:05:48 +05:30
click_button s_('GroupSettings|Transfer group')
2022-04-04 11:22:00 +05:30
page.within(confirm_modal) do
2022-05-07 20:08:51 +05:30
expect(page).to have_text "You are going to transfer #{selected_group.name} to another namespace. Are you ABSOLUTELY sure?"
2022-04-04 11:22:00 +05:30
2023-04-23 21:23:45 +05:30
fill_in 'confirm_name_input', with: selected_group.full_path
2022-05-07 20:08:51 +05:30
click_button 'Confirm'
2022-04-04 11:22:00 +05:30
end
2023-05-27 22:25:52 +05:30
within('[data-testid="breadcrumb-links"]') do
2023-06-20 00:43:36 +05:30
expect(page).to have_content(target_group.name) if target_group
2023-05-27 22:25:52 +05:30
expect(page).to have_content(selected_group.name)
end
2023-06-20 00:43:36 +05:30
if target_group
expect(current_url).to include("#{target_group.path}/#{selected_group_path}")
else
expect(current_url).to include(selected_group_path)
end
2022-04-04 11:22:00 +05:30
end
end
2023-01-13 00:05:48 +05:30
context 'when transfering from a subgroup' do
2022-04-04 11:22:00 +05:30
let(:selected_group) { create(:group, path: 'foo-subgroup', parent: group) }
2023-01-13 00:05:48 +05:30
context 'when transfering to no parent group' do
2023-06-20 00:43:36 +05:30
let(:target_group) { nil }
2022-05-07 20:08:51 +05:30
it_behaves_like 'can transfer the group'
end
2023-01-13 00:05:48 +05:30
context 'when transfering to a parent group' do
2022-05-07 20:08:51 +05:30
let(:target_group) { create(:group, path: 'foo-parentgroup') }
before do
target_group.add_owner(user)
end
it_behaves_like 'can transfer the group'
end
2022-04-04 11:22:00 +05:30
end
2023-01-13 00:05:48 +05:30
context 'when transfering from a root group to a parent group' do
2022-04-04 11:22:00 +05:30
let(:selected_group) { create(:group, path: 'foo-rootgroup') }
2023-06-20 00:43:36 +05:30
let(:target_group) { group }
2022-04-04 11:22:00 +05:30
2023-01-13 00:05:48 +05:30
it_behaves_like 'can transfer the group'
2022-04-04 11:22:00 +05:30
end
end
2020-01-01 13:55:28 +05:30
context 'disable email notifications' do
it 'is visible' do
visit edit_group_path(group)
expect(page).to have_selector('#group_emails_disabled', visible: true)
end
it 'accepts the changed state' do
visit edit_group_path(group)
check 'group_emails_disabled'
expect { save_permissions_group }.to change { updated_emails_disabled? }.to(true)
end
end
2021-09-04 01:27:46 +05:30
describe 'prevent sharing outside group hierarchy setting' do
it 'updates the setting' do
visit edit_group_path(group)
check 'group_prevent_sharing_groups_outside_hierarchy'
expect { save_permissions_group }.to change {
2022-07-16 23:28:13 +05:30
group.reload.prevent_sharing_groups_outside_hierarchy
2021-09-04 01:27:46 +05:30
}.to(true)
end
it 'is not present for a subgroup' do
subgroup = create(:group, parent: group)
visit edit_group_path(subgroup)
expect(page).to have_text "Permissions"
expect(page).not_to have_selector('#group_prevent_sharing_groups_outside_hierarchy')
end
end
2023-06-20 00:43:36 +05:30
describe 'group README', :js do
let_it_be(:group) { create(:group) }
context 'with gitlab-profile project and README.md' do
let_it_be(:project) { create(:project, :readme, namespace: group) }
it 'renders link to Group README and navigates to it on click' do
visit edit_group_path(group)
wait_for_requests
click_link('README')
wait_for_requests
expect(page).to have_current_path(project_blob_path(project, "#{project.default_branch}/README.md"))
expect(page).to have_text('README.md')
end
end
context 'with gitlab-profile project and no README.md' do
2023-07-09 08:55:56 +05:30
let_it_be(:project) { create(:project, path: 'gitlab-profile', namespace: group) }
2023-06-20 00:43:36 +05:30
it 'renders Add README button and allows user to create a README via the IDE' do
visit edit_group_path(group)
wait_for_requests
expect(page).not_to have_selector('.ide')
click_button('Add README')
accept_gl_confirm("This will create a README.md for project #{group.readme_project.present.path_with_namespace}.", button_text: 'Add README')
wait_for_requests
expect(page).to have_current_path("/-/ide/project/#{group.readme_project.present.path_with_namespace}/edit/main/-/README.md/")
page.within('.ide') do
expect(page).to have_text('README.md')
end
end
end
context 'with no gitlab-profile project and no README.md' do
it 'renders Add README button and allows user to create both the gitlab-profile project and README via the IDE' do
visit edit_group_path(group)
wait_for_requests
expect(page).not_to have_selector('.ide')
click_button('Add README')
accept_gl_confirm("This will create a project #{group.full_path}/gitlab-profile and add a README.md.", button_text: 'Create and add README')
wait_for_requests
expect(page).to have_current_path("/-/ide/project/#{group.full_path}/gitlab-profile/edit/main/-/README.md/")
page.within('.ide') do
expect(page).to have_text('README.md')
end
end
end
end
2018-11-08 19:23:39 +05:30
def update_path(new_group_path)
visit edit_group_path(group)
page.within('.gs-advanced') do
fill_in 'group_path', with: new_group_path
2020-10-24 23:57:45 +05:30
click_button 'Change group URL'
2018-11-08 19:23:39 +05:30
end
end
2020-01-01 13:55:28 +05:30
def save_general_group
2018-11-08 19:23:39 +05:30
page.within('.gs-general') do
2018-12-13 13:39:08 +05:30
click_button 'Save changes'
2018-11-08 19:23:39 +05:30
end
end
2020-01-01 13:55:28 +05:30
def save_permissions_group
page.within('.gs-permissions') do
click_button 'Save changes'
end
end
def updated_emails_disabled?
2021-04-29 21:17:54 +05:30
group.reload.clear_memoization(:emails_disabled_memoized)
2020-01-01 13:55:28 +05:30
group.emails_disabled?
end
2017-08-17 22:00:37 +05:30
end