2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-29 06:30:33 -04:00
|
|
|
require 'spec_helper'
|
2016-11-03 09:47:15 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'New project' do
|
2017-08-26 02:50:12 -04:00
|
|
|
include Select2Helper
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'as a user' do
|
|
|
|
let(:user) { create(:user) }
|
2016-11-03 09:47:15 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
2016-11-03 09:47:15 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'shows a message if multiple levels are restricted' do
|
|
|
|
Gitlab::CurrentSettings.update!(
|
|
|
|
restricted_visibility_levels: [Gitlab::VisibilityLevel::PRIVATE, Gitlab::VisibilityLevel::INTERNAL]
|
|
|
|
)
|
2017-06-29 06:30:33 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
visit new_project_path
|
2017-06-29 06:30:33 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(page).to have_content 'Other visibility settings have been disabled by the administrator.'
|
|
|
|
end
|
2017-10-11 05:07:19 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'shows a message if all levels are restricted' do
|
|
|
|
Gitlab::CurrentSettings.update!(
|
|
|
|
restricted_visibility_levels: Gitlab::VisibilityLevel.values
|
|
|
|
)
|
2017-06-29 06:30:33 -04:00
|
|
|
|
2018-07-10 05:44:37 -04:00
|
|
|
visit new_project_path
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(page).to have_content 'Visibility settings have been disabled by the administrator.'
|
2018-07-10 05:44:37 -04:00
|
|
|
end
|
2019-06-28 17:38:26 -04:00
|
|
|
end
|
2018-07-10 05:44:37 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'as an admin' do
|
|
|
|
let(:user) { create(:admin) }
|
2018-07-10 05:44:37 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
2018-07-10 05:44:37 -04:00
|
|
|
end
|
2017-06-29 06:30:33 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'shows "New project" page', :js do
|
|
|
|
visit new_project_path
|
2016-11-03 09:47:15 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(page).to have_content('Project name')
|
|
|
|
expect(page).to have_content('Project URL')
|
|
|
|
expect(page).to have_content('Project slug')
|
2017-03-11 08:59:09 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
find('#import-project-tab').click
|
2017-03-11 08:59:09 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(page).to have_link('GitHub')
|
|
|
|
expect(page).to have_link('Bitbucket')
|
|
|
|
expect(page).to have_link('GitLab.com')
|
|
|
|
expect(page).to have_link('Google Code')
|
|
|
|
expect(page).to have_button('Repo by URL')
|
|
|
|
expect(page).to have_link('GitLab export')
|
2016-11-03 09:47:15 -04:00
|
|
|
end
|
2019-05-26 01:42:42 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
describe 'manifest import option' do
|
2019-05-26 01:42:42 -04:00
|
|
|
before do
|
2019-06-28 17:38:26 -04:00
|
|
|
visit new_project_path
|
|
|
|
|
|
|
|
find('#import-project-tab').click
|
2019-05-26 01:42:42 -04:00
|
|
|
end
|
|
|
|
|
2019-06-13 09:12:28 -04:00
|
|
|
it { expect(page).to have_link('Manifest file') }
|
2019-05-26 01:42:42 -04:00
|
|
|
end
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'Visibility level selector', :js do
|
|
|
|
Gitlab::VisibilityLevel.options.each do |key, level|
|
|
|
|
it "sets selector to #{key}" do
|
|
|
|
stub_application_setting(default_project_visibility: level)
|
|
|
|
|
|
|
|
visit new_project_path
|
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
expect(find_field("project_visibility_level_#{level}")).to be_checked
|
|
|
|
end
|
|
|
|
end
|
2019-05-26 01:42:42 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it "saves visibility level #{level} on validation error" do
|
|
|
|
visit new_project_path
|
2019-05-26 01:42:42 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
choose(s_(key))
|
|
|
|
click_button('Create project')
|
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
expect(find_field("project_visibility_level_#{level}")).to be_checked
|
|
|
|
end
|
2019-05-26 01:42:42 -04:00
|
|
|
end
|
|
|
|
end
|
2017-01-30 12:43:13 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'when group visibility is private but default is internal' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(default_project_visibility: Gitlab::VisibilityLevel::INTERNAL)
|
|
|
|
end
|
2018-07-03 09:09:58 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'has private selected' do
|
|
|
|
group = create(:group, visibility_level: Gitlab::VisibilityLevel::PRIVATE)
|
|
|
|
visit new_project_path(namespace_id: group.id)
|
2018-09-13 07:39:07 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
expect(find_field("project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).to be_checked
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when group visibility is public but user requests private' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(default_project_visibility: Gitlab::VisibilityLevel::INTERNAL)
|
|
|
|
end
|
2018-09-13 07:39:07 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'has private selected' do
|
|
|
|
group = create(:group, visibility_level: Gitlab::VisibilityLevel::PUBLIC)
|
|
|
|
visit new_project_path(namespace_id: group.id, project: { visibility_level: Gitlab::VisibilityLevel::PRIVATE })
|
|
|
|
|
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
expect(find_field("project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).to be_checked
|
|
|
|
end
|
|
|
|
end
|
2018-09-13 07:39:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'Readme selector' do
|
|
|
|
it 'shows the initialize with Readme checkbox on "Blank project" tab' do
|
|
|
|
visit new_project_path
|
2018-09-13 07:39:07 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(page).to have_css('input#project_initialize_with_readme')
|
|
|
|
expect(page).to have_content('Initialize repository with a README')
|
2018-09-13 07:39:07 -04:00
|
|
|
end
|
2018-07-03 09:09:58 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'does not show the initialize with Readme checkbox on "Create from template" tab' do
|
2017-02-20 12:01:37 -05:00
|
|
|
visit new_project_path
|
2019-06-28 17:38:26 -04:00
|
|
|
find('#create-from-template-pane').click
|
|
|
|
first('.choose-template').click
|
|
|
|
|
|
|
|
page.within '.project-fields-form' do
|
|
|
|
expect(page).not_to have_css('input#project_initialize_with_readme')
|
|
|
|
expect(page).not_to have_content('Initialize repository with a README')
|
|
|
|
end
|
2017-02-20 12:01:37 -05:00
|
|
|
end
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'does not show the initialize with Readme checkbox on "Import project" tab' do
|
|
|
|
visit new_project_path
|
|
|
|
find('#import-project-tab').click
|
|
|
|
first('.js-import-git-toggle-button').click
|
2017-02-20 12:01:37 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
page.within '.toggle-import-form' do
|
|
|
|
expect(page).not_to have_css('input#project_initialize_with_readme')
|
|
|
|
expect(page).not_to have_content('Initialize repository with a README')
|
2017-10-11 05:07:19 -04:00
|
|
|
end
|
2017-02-20 12:01:37 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'Namespace selector' do
|
|
|
|
context 'with user namespace' do
|
|
|
|
before do
|
|
|
|
visit new_project_path
|
|
|
|
end
|
2017-02-20 12:01:37 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'selects the user namespace' do
|
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
namespace = find('#project_namespace_id')
|
|
|
|
|
|
|
|
expect(namespace.text).to eq user.username
|
|
|
|
end
|
|
|
|
end
|
2017-02-20 12:01:37 -05:00
|
|
|
end
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'with group namespace' do
|
|
|
|
let(:group) { create(:group, :private) }
|
2017-02-20 12:01:37 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
before do
|
|
|
|
group.add_owner(user)
|
|
|
|
visit new_project_path(namespace_id: group.id)
|
2017-10-11 05:07:19 -04:00
|
|
|
end
|
2017-04-05 13:20:11 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'selects the group namespace' do
|
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
namespace = find('#project_namespace_id option[selected]')
|
2017-04-05 13:20:11 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(namespace.text).to eq group.name
|
|
|
|
end
|
|
|
|
end
|
2017-04-05 13:20:11 -04:00
|
|
|
end
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'with subgroup namespace' do
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:subgroup) { create(:group, parent: group) }
|
2017-04-05 13:20:11 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
before do
|
|
|
|
group.add_maintainer(user)
|
|
|
|
visit new_project_path(namespace_id: subgroup.id)
|
2017-10-11 05:07:19 -04:00
|
|
|
end
|
2017-08-26 02:50:12 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'selects the group namespace' do
|
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
namespace = find('#project_namespace_id option[selected]')
|
2017-08-26 02:50:12 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(namespace.text).to eq subgroup.full_path
|
|
|
|
end
|
|
|
|
end
|
2017-08-26 02:50:12 -04:00
|
|
|
end
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'when changing namespaces dynamically', :js do
|
|
|
|
let(:public_group) { create(:group, :public) }
|
|
|
|
let(:internal_group) { create(:group, :internal) }
|
|
|
|
let(:private_group) { create(:group, :private) }
|
2017-02-20 12:01:37 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
before do
|
|
|
|
public_group.add_owner(user)
|
|
|
|
internal_group.add_owner(user)
|
|
|
|
private_group.add_owner(user)
|
|
|
|
visit new_project_path(namespace_id: public_group.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'enables the correct visibility options' do
|
|
|
|
select2(user.namespace_id, from: '#project_namespace_id')
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).not_to be_disabled
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).not_to be_disabled
|
|
|
|
|
|
|
|
select2(public_group.id, from: '#project_namespace_id')
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).not_to be_disabled
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).not_to be_disabled
|
|
|
|
|
|
|
|
select2(internal_group.id, from: '#project_namespace_id')
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).not_to be_disabled
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).to be_disabled
|
|
|
|
|
|
|
|
select2(private_group.id, from: '#project_namespace_id')
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).to be_disabled
|
|
|
|
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).to be_disabled
|
|
|
|
end
|
|
|
|
end
|
2017-01-30 12:43:13 -05:00
|
|
|
end
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'Import project options', :js do
|
2017-06-29 06:30:33 -04:00
|
|
|
before do
|
2019-06-28 17:38:26 -04:00
|
|
|
visit new_project_path
|
|
|
|
find('#import-project-tab').click
|
2017-06-29 06:30:33 -04:00
|
|
|
end
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'from git repository url, "Repo by URL"' do
|
|
|
|
before do
|
|
|
|
first('.js-import-git-toggle-button').click
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not autocomplete sensitive git repo URL' do
|
|
|
|
autocomplete = find('#project_import_url')['autocomplete']
|
2017-06-29 06:30:33 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(autocomplete).to eq('off')
|
|
|
|
end
|
2017-06-29 06:30:33 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'shows import instructions' do
|
|
|
|
git_import_instructions = first('.js-toggle-content')
|
2017-01-30 12:43:13 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(git_import_instructions).to be_visible
|
|
|
|
expect(git_import_instructions).to have_content 'Git repository URL'
|
|
|
|
end
|
2018-02-14 18:52:36 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'keeps "Import project" tab open after form validation error' do
|
|
|
|
collision_project = create(:project, name: 'test-name-collision', namespace: user.namespace)
|
2018-02-14 18:52:36 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
fill_in 'project_import_url', with: collision_project.http_url_to_repo
|
|
|
|
fill_in 'project_name', with: collision_project.name
|
2018-02-14 18:52:36 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
click_on 'Create project'
|
2018-02-14 18:52:36 -05:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(page).to have_css('#import-project-pane.active')
|
|
|
|
expect(page).not_to have_css('.toggle-import-form.hide')
|
|
|
|
end
|
2018-02-14 18:52:36 -05:00
|
|
|
end
|
2017-06-29 06:30:33 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'from GitHub' do
|
|
|
|
before do
|
|
|
|
first('.js-import-github').click
|
|
|
|
end
|
2017-06-29 06:30:33 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'shows import instructions' do
|
2019-08-22 19:20:19 -04:00
|
|
|
expect(page).to have_content('Authenticate with GitHub')
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(current_path).to eq new_import_github_path
|
|
|
|
end
|
2017-06-29 06:30:33 -04:00
|
|
|
end
|
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'from Google Code' do
|
|
|
|
before do
|
|
|
|
first('.import_google_code').click
|
|
|
|
end
|
2017-06-29 06:30:33 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'shows import instructions' do
|
|
|
|
expect(page).to have_content('Import projects from Google Code')
|
|
|
|
expect(current_path).to eq new_import_google_code_path
|
|
|
|
end
|
2017-06-29 06:30:33 -04:00
|
|
|
end
|
2018-07-06 06:59:48 -04:00
|
|
|
|
2019-07-24 05:20:54 -04:00
|
|
|
context 'from manifest file' do
|
2019-06-28 17:38:26 -04:00
|
|
|
before do
|
|
|
|
first('.import_manifest').click
|
|
|
|
end
|
2018-07-06 06:59:48 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'shows import instructions' do
|
|
|
|
expect(page).to have_content('Manifest file import')
|
|
|
|
expect(current_path).to eq new_import_manifest_path
|
|
|
|
end
|
2018-07-06 06:59:48 -04:00
|
|
|
end
|
|
|
|
end
|
2019-04-05 14:49:46 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
context 'Namespace selector' do
|
|
|
|
context 'with group with DEVELOPER_MAINTAINER_PROJECT_ACCESS project_creation_level' do
|
|
|
|
let(:group) { create(:group, project_creation_level: ::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS) }
|
2019-04-05 14:49:46 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
before do
|
|
|
|
group.add_developer(user)
|
|
|
|
visit new_project_path(namespace_id: group.id)
|
|
|
|
end
|
2019-04-05 14:49:46 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
it 'selects the group namespace' do
|
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
namespace = find('#project_namespace_id option[selected]')
|
2019-04-05 14:49:46 -04:00
|
|
|
|
2019-06-28 17:38:26 -04:00
|
|
|
expect(namespace.text).to eq group.full_path
|
|
|
|
end
|
2019-04-05 14:49:46 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-11-03 09:47:15 -04:00
|
|
|
end
|