debian-mirror-gitlab/spec/features/projects/user_changes_project_visibility_spec.rb

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

114 lines
2.9 KiB
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'User changes public project visibility', :js do
2020-01-01 13:55:28 +05:30
include ProjectForksHelper
shared_examples 'changing visibility to private' do
it 'requires confirmation' do
visibility_select = first('.project-feature-controls .select-control')
visibility_select.select('Private')
page.within('#js-shared-permissions') do
click_button 'Save changes'
end
2022-03-02 08:16:31 +05:30
fill_in 'confirm_name_input', with: project.path_with_namespace
2020-01-01 13:55:28 +05:30
page.within '.modal' do
click_button 'Reduce project visibility'
end
2021-06-08 01:23:25 +05:30
wait_for_requests
expect(project.reload).to be_private
2020-01-01 13:55:28 +05:30
end
end
2022-03-02 08:16:31 +05:30
shared_examples 'does not require confirmation' do
it 'saves without confirmation' do
visibility_select = first('.project-feature-controls .select-control')
visibility_select.select('Private')
page.within('#js-shared-permissions') do
click_button 'Save changes'
end
wait_for_requests
expect(project.reload).to be_private
end
end
context 'when the project has forks' do
before do
2022-04-04 11:22:00 +05:30
fork_project(project, project.first_owner)
2022-03-02 08:16:31 +05:30
2022-04-04 11:22:00 +05:30
sign_in(project.first_owner)
2022-03-02 08:16:31 +05:30
visit edit_project_path(project)
end
context 'when a project is public' do
let(:project) { create(:project, :empty_repo, :public) }
it_behaves_like 'changing visibility to private'
end
context 'when the project is internal' do
let(:project) { create(:project, :empty_repo, :internal) }
it_behaves_like 'changing visibility to private'
end
context 'when the visibility level is untouched' do
let(:project) { create(:project, :empty_repo, :public) }
it 'saves without confirmation' do
expect(page).to have_selector('.js-emails-disabled', visible: true)
find('.js-emails-disabled input[type="checkbox"]').click
page.within('#js-shared-permissions') do
click_button 'Save changes'
end
wait_for_requests
expect(project.reload).to be_public
end
end
end
context 'when the project is not forked' do
2020-01-01 13:55:28 +05:30
let(:project) { create(:project, :empty_repo, :public) }
2022-03-02 08:16:31 +05:30
before do
2022-04-04 11:22:00 +05:30
sign_in(project.first_owner)
2022-03-02 08:16:31 +05:30
visit edit_project_path(project)
end
it_behaves_like 'does not require confirmation'
2020-01-01 13:55:28 +05:30
end
2022-03-02 08:16:31 +05:30
context 'with unlink_fork_network_upon_visibility_decrease = false' do
let(:project) { create(:project, :empty_repo, :public) }
before do
stub_feature_flags(unlink_fork_network_upon_visibility_decrease: false)
2022-04-04 11:22:00 +05:30
fork_project(project, project.first_owner)
2022-03-02 08:16:31 +05:30
2022-04-04 11:22:00 +05:30
sign_in(project.first_owner)
2022-03-02 08:16:31 +05:30
visit edit_project_path(project)
2023-01-13 00:05:48 +05:30
# https://gitlab.com/gitlab-org/gitlab/-/issues/381259
allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(110)
2022-03-02 08:16:31 +05:30
end
2020-01-01 13:55:28 +05:30
2022-03-02 08:16:31 +05:30
it_behaves_like 'does not require confirmation'
2020-01-01 13:55:28 +05:30
end
end