2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-22 02:09:56 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 18:08:28 +00:00
|
|
|
RSpec.describe 'Projects > Settings > Visibility settings', :js do
|
2016-11-22 02:09:56 +00:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, namespace: user.namespace, visibility_level: 20) }
|
2016-11-22 02:09:56 +00:00
|
|
|
|
|
|
|
context 'as owner' do
|
|
|
|
before do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit edit_project_path(project)
|
2016-11-22 02:09:56 +00:00
|
|
|
end
|
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
it 'project visibility select is available' do
|
2017-09-07 18:07:40 +00:00
|
|
|
visibility_select_container = find('.project-visibility-setting')
|
2016-11-22 17:16:30 +00:00
|
|
|
|
2017-09-07 18:07:40 +00:00
|
|
|
expect(visibility_select_container.find('select').value).to eq project.visibility_level.to_s
|
|
|
|
expect(visibility_select_container).to have_content 'The project can be accessed by anyone, regardless of authentication.'
|
2016-11-22 02:09:56 +00:00
|
|
|
end
|
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
it 'project visibility description updates on change' do
|
2017-09-07 18:07:40 +00:00
|
|
|
visibility_select_container = find('.project-visibility-setting')
|
|
|
|
visibility_select = visibility_select_container.find('select')
|
2016-11-22 02:09:56 +00:00
|
|
|
visibility_select.select('Private')
|
2016-11-22 17:16:30 +00:00
|
|
|
|
2016-11-22 02:09:56 +00:00
|
|
|
expect(visibility_select.value).to eq '0'
|
2017-09-07 18:07:40 +00:00
|
|
|
expect(visibility_select_container).to have_content 'Access must be granted explicitly to each user.'
|
2016-11-22 02:09:56 +00:00
|
|
|
end
|
2018-04-06 12:40:33 +00:00
|
|
|
|
|
|
|
context 'merge requests select' do
|
|
|
|
it 'hides merge requests section' do
|
|
|
|
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
|
|
|
|
|
|
|
|
expect(page).to have_selector('.merge-requests-feature', visible: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'given project with merge_requests_disabled access level' do
|
|
|
|
let(:project) { create(:project, :merge_requests_disabled, namespace: user.namespace) }
|
|
|
|
|
|
|
|
it 'hides merge requests section' do
|
|
|
|
expect(page).to have_selector('.merge-requests-feature', visible: false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'builds select' do
|
|
|
|
it 'hides builds select section' do
|
|
|
|
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click
|
|
|
|
|
|
|
|
expect(page).to have_selector('.builds-feature', visible: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'given project with builds_disabled access level' do
|
|
|
|
let(:project) { create(:project, :builds_disabled, namespace: user.namespace) }
|
|
|
|
|
|
|
|
it 'hides builds select section' do
|
|
|
|
expect(page).to have_selector('.builds-feature', visible: false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-08-17 05:56:48 +00:00
|
|
|
|
|
|
|
context 'disable email notifications' do
|
|
|
|
it 'is visible' do
|
|
|
|
expect(page).to have_selector('.js-emails-disabled', visible: true)
|
|
|
|
end
|
2019-12-04 12:07:12 +00:00
|
|
|
|
|
|
|
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-08-17 05:56:48 +00:00
|
|
|
end
|
2016-11-22 02:09:56 +00:00
|
|
|
end
|
|
|
|
|
2018-07-11 14:36:08 +00:00
|
|
|
context 'as maintainer' do
|
|
|
|
let(:maintainer_user) { create(:user) }
|
2016-11-22 02:09:56 +00:00
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(maintainer_user)
|
|
|
|
sign_in(maintainer_user)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit edit_project_path(project)
|
2016-11-22 02:09:56 +00:00
|
|
|
end
|
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
it 'project visibility is locked' do
|
2017-09-07 18:07:40 +00:00
|
|
|
visibility_select_container = find('.project-visibility-setting')
|
2016-11-22 17:16:30 +00:00
|
|
|
|
2017-09-07 18:07:40 +00:00
|
|
|
expect(visibility_select_container).to have_selector 'select[name="project[visibility_level]"]:disabled'
|
|
|
|
expect(visibility_select_container).to have_content 'The project can be accessed by anyone, regardless of authentication.'
|
2016-11-22 02:09:56 +00:00
|
|
|
end
|
2019-08-17 05:56:48 +00:00
|
|
|
|
|
|
|
context 'disable email notifications' do
|
|
|
|
it 'is not available' do
|
|
|
|
expect(page).not_to have_selector('.js-emails-disabled', visible: true)
|
|
|
|
end
|
|
|
|
end
|
2016-11-22 02:09:56 +00:00
|
|
|
end
|
2019-12-04 12:07:12 +00:00
|
|
|
|
|
|
|
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
|
2016-11-22 02:09:56 +00:00
|
|
|
end
|