2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'User changes public project visibility', :js, feature_category: :projects 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
|
|
|
|
end
|