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 'Projects > Settings > Visibility settings', :js, feature_category: :projects do
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, namespace: user.namespace, visibility_level: 20) }
|
|
|
|
|
|
|
|
context 'as owner' do
|
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
|
|
|
visit edit_project_path(project)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
it 'project visibility select is available' do
|
2018-03-17 18:26:18 +05:30
|
|
|
visibility_select_container = find('.project-visibility-setting')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(visibility_select_container.find('select').value).to eq project.visibility_level.to_s
|
2022-08-13 15:12:31 +05:30
|
|
|
expect(visibility_select_container).to have_content 'Accessible by anyone, regardless of authentication.'
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
it 'project visibility description updates on change' do
|
2018-03-17 18:26:18 +05:30
|
|
|
visibility_select_container = find('.project-visibility-setting')
|
|
|
|
visibility_select = visibility_select_container.find('select')
|
2017-08-17 22:00:37 +05:30
|
|
|
visibility_select.select('Private')
|
|
|
|
|
|
|
|
expect(visibility_select.value).to eq '0'
|
2022-08-13 15:12:31 +05:30
|
|
|
expect(visibility_select_container).to have_content 'Only accessible by project members. Membership must be explicitly granted to each user.'
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2018-10-15 14:42:47 +05:30
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
context 'disable email notifications' do
|
|
|
|
it 'is visible' do
|
|
|
|
expect(page).to have_selector('.js-emails-disabled', visible: true)
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
it 'accepts the changed state' do
|
|
|
|
find('.js-emails-disabled input[type="checkbox"]').click
|
|
|
|
|
|
|
|
expect { save_permissions_group }.to change { updated_emails_disabled? }.to(true)
|
|
|
|
end
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
context 'as maintainer' do
|
|
|
|
let(:maintainer_user) { create(:user) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(maintainer_user)
|
|
|
|
sign_in(maintainer_user)
|
2017-09-10 17:25:29 +05:30
|
|
|
visit edit_project_path(project)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
it 'project visibility is locked' do
|
2018-03-17 18:26:18 +05:30
|
|
|
visibility_select_container = find('.project-visibility-setting')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(visibility_select_container).to have_selector 'select[name="project[visibility_level]"]:disabled'
|
2022-08-13 15:12:31 +05:30
|
|
|
expect(visibility_select_container).to have_content 'Accessible by anyone, regardless of authentication.'
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2019-10-12 21:52:04 +05:30
|
|
|
|
|
|
|
context 'disable email notifications' do
|
|
|
|
it 'is not available' do
|
|
|
|
expect(page).not_to have_selector('.js-emails-disabled', visible: true)
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
def save_permissions_group
|
|
|
|
page.within('.sharing-permissions') do
|
|
|
|
click_button 'Save changes'
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def updated_emails_disabled?
|
|
|
|
project.reload.clear_memoization(:emails_disabled)
|
|
|
|
project.emails_disabled?
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|