2017-06-29 10:30:33 +00:00
|
|
|
require 'spec_helper'
|
2016-11-03 13:47:15 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
describe 'New project' do
|
2017-08-26 06:50:12 +00:00
|
|
|
include Select2Helper
|
|
|
|
|
2017-01-30 17:43:13 +00:00
|
|
|
let(:user) { create(:admin) }
|
2016-11-03 13:47:15 +00:00
|
|
|
|
2017-01-30 17:43:13 +00:00
|
|
|
before do
|
2017-06-29 10:30:33 +00:00
|
|
|
sign_in(user)
|
2017-01-30 17:43:13 +00:00
|
|
|
end
|
2016-11-03 13:47:15 +00:00
|
|
|
|
2017-10-11 09:07:19 +00:00
|
|
|
it 'shows "New project" page', :js do
|
2017-06-29 10:30:33 +00:00
|
|
|
visit new_project_path
|
|
|
|
|
|
|
|
expect(page).to have_content('Project name')
|
2018-09-08 06:03:00 +00:00
|
|
|
expect(page).to have_content('Project URL')
|
|
|
|
expect(page).to have_content('Project slug')
|
2017-06-29 10:30:33 +00:00
|
|
|
|
2017-10-23 10:55:15 +00:00
|
|
|
find('#import-project-tab').click
|
2017-10-11 09:07:19 +00:00
|
|
|
|
2017-06-29 10:30:33 +00: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')
|
|
|
|
end
|
|
|
|
|
2018-07-10 09:44:37 +00:00
|
|
|
describe 'manifest import option' do
|
|
|
|
before do
|
|
|
|
visit new_project_path
|
|
|
|
|
|
|
|
find('#import-project-tab').click
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when using postgres', :postgresql do
|
|
|
|
it { expect(page).to have_link('Manifest file') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when using mysql', :mysql do
|
|
|
|
it { expect(page).not_to have_link('Manifest file') }
|
|
|
|
end
|
2017-06-29 10:30:33 +00:00
|
|
|
end
|
|
|
|
|
2017-10-11 09:07:19 +00:00
|
|
|
context 'Visibility level selector', :js do
|
2016-11-03 13:47:15 +00:00
|
|
|
Gitlab::VisibilityLevel.options.each do |key, level|
|
|
|
|
it "sets selector to #{key}" do
|
|
|
|
stub_application_setting(default_project_visibility: level)
|
|
|
|
|
|
|
|
visit new_project_path
|
2017-10-11 09:07:19 +00:00
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
expect(find_field("project_visibility_level_#{level}")).to be_checked
|
|
|
|
end
|
2016-11-03 13:47:15 +00:00
|
|
|
end
|
2017-03-11 13:59:09 +00:00
|
|
|
|
2017-06-07 20:13:44 +00:00
|
|
|
it "saves visibility level #{level} on validation error" do
|
2017-03-11 21:01:43 +00:00
|
|
|
visit new_project_path
|
2017-03-11 13:59:09 +00:00
|
|
|
|
2017-06-07 20:13:44 +00:00
|
|
|
choose(s_(key))
|
2017-03-11 21:01:43 +00:00
|
|
|
click_button('Create project')
|
2017-10-11 09:07:19 +00:00
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
expect(find_field("project_visibility_level_#{level}")).to be_checked
|
|
|
|
end
|
2017-03-11 13:59:09 +00:00
|
|
|
end
|
2016-11-03 13:47:15 +00:00
|
|
|
end
|
|
|
|
end
|
2017-01-30 17:43:13 +00:00
|
|
|
|
2018-07-03 13:09:58 +00:00
|
|
|
context 'Readme selector' do
|
|
|
|
it 'shows the initialize with Readme checkbox' do
|
|
|
|
visit new_project_path
|
|
|
|
|
|
|
|
expect(page).to have_css('input#project_initialize_with_readme')
|
|
|
|
expect(page).to have_content('Initialize repository with a README')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-29 10:30:33 +00:00
|
|
|
context 'Namespace selector' do
|
|
|
|
context 'with user namespace' do
|
2017-02-20 17:01:37 +00:00
|
|
|
before do
|
|
|
|
visit new_project_path
|
|
|
|
end
|
|
|
|
|
2017-06-29 10:30:33 +00:00
|
|
|
it 'selects the user namespace' do
|
2017-10-11 09:07:19 +00:00
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
namespace = find('#project_namespace_id')
|
2017-02-20 17:01:37 +00:00
|
|
|
|
2017-10-11 09:07:19 +00:00
|
|
|
expect(namespace.text).to eq user.username
|
|
|
|
end
|
2017-02-20 17:01:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-29 10:30:33 +00:00
|
|
|
context 'with group namespace' do
|
2018-04-23 15:48:26 +00:00
|
|
|
let(:group) { create(:group, :private) }
|
2017-02-20 17:01:37 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_owner(user)
|
|
|
|
visit new_project_path(namespace_id: group.id)
|
|
|
|
end
|
|
|
|
|
2017-06-29 10:30:33 +00:00
|
|
|
it 'selects the group namespace' do
|
2017-10-11 09:07:19 +00:00
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
namespace = find('#project_namespace_id option[selected]')
|
2017-02-20 17:01:37 +00:00
|
|
|
|
2017-10-11 09:07:19 +00:00
|
|
|
expect(namespace.text).to eq group.name
|
|
|
|
end
|
2017-02-20 17:01:37 +00:00
|
|
|
end
|
|
|
|
end
|
2017-04-05 17:20:11 +00:00
|
|
|
|
2017-06-29 10:30:33 +00:00
|
|
|
context 'with subgroup namespace' do
|
2018-04-23 15:48:26 +00:00
|
|
|
let(:group) { create(:group) }
|
2017-04-05 17:20:11 +00:00
|
|
|
let(:subgroup) { create(:group, parent: group) }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
group.add_maintainer(user)
|
2017-04-05 17:20:11 +00:00
|
|
|
visit new_project_path(namespace_id: subgroup.id)
|
|
|
|
end
|
|
|
|
|
2017-06-29 10:30:33 +00:00
|
|
|
it 'selects the group namespace' do
|
2017-10-11 09:07:19 +00:00
|
|
|
page.within('#blank-project-pane') do
|
|
|
|
namespace = find('#project_namespace_id option[selected]')
|
2017-04-05 17:20:11 +00:00
|
|
|
|
2017-10-11 09:07:19 +00:00
|
|
|
expect(namespace.text).to eq subgroup.full_path
|
|
|
|
end
|
2017-04-05 17:20:11 +00:00
|
|
|
end
|
|
|
|
end
|
2017-08-26 06:50:12 +00: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) }
|
|
|
|
|
|
|
|
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-02-20 17:01:37 +00:00
|
|
|
end
|
|
|
|
|
2017-10-11 09:07:19 +00:00
|
|
|
context 'Import project options', :js do
|
2017-01-30 17:43:13 +00:00
|
|
|
before do
|
|
|
|
visit new_project_path
|
2017-10-23 10:55:15 +00:00
|
|
|
find('#import-project-tab').click
|
2017-01-30 17:43:13 +00:00
|
|
|
end
|
|
|
|
|
2018-02-14 23:52:36 +00:00
|
|
|
context 'from git repository url, "Repo by URL"' do
|
2017-06-29 10:30:33 +00:00
|
|
|
before do
|
2018-02-21 02:23:49 +00:00
|
|
|
first('.js-import-git-toggle-button').click
|
2017-06-29 10:30:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not autocomplete sensitive git repo URL' do
|
|
|
|
autocomplete = find('#project_import_url')['autocomplete']
|
|
|
|
|
|
|
|
expect(autocomplete).to eq('off')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows import instructions' do
|
|
|
|
git_import_instructions = first('.js-toggle-content')
|
2017-01-30 17:43:13 +00:00
|
|
|
|
2017-06-29 10:30:33 +00:00
|
|
|
expect(git_import_instructions).to be_visible
|
|
|
|
expect(git_import_instructions).to have_content 'Git repository URL'
|
|
|
|
end
|
2018-02-14 23:52:36 +00:00
|
|
|
|
|
|
|
it 'keeps "Import project" tab open after form validation error' do
|
|
|
|
collision_project = create(:project, name: 'test-name-collision', namespace: user.namespace)
|
|
|
|
|
|
|
|
fill_in 'project_import_url', with: collision_project.http_url_to_repo
|
2018-09-08 06:03:00 +00:00
|
|
|
fill_in 'project_name', with: collision_project.name
|
2018-02-14 23:52:36 +00:00
|
|
|
|
|
|
|
click_on 'Create project'
|
|
|
|
|
|
|
|
expect(page).to have_css('#import-project-pane.active')
|
|
|
|
expect(page).not_to have_css('.toggle-import-form.hide')
|
|
|
|
end
|
2017-06-29 10:30:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'from GitHub' do
|
|
|
|
before do
|
2018-03-07 15:58:50 +00:00
|
|
|
first('.js-import-github').click
|
2017-06-29 10:30:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows import instructions' do
|
2018-03-07 15:58:50 +00:00
|
|
|
expect(page).to have_content('Import repositories from GitHub')
|
2017-06-29 10:30:33 +00:00
|
|
|
expect(current_path).to eq new_import_github_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'from Google Code' do
|
|
|
|
before do
|
|
|
|
first('.import_google_code').click
|
|
|
|
end
|
|
|
|
|
|
|
|
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-01-30 17:43:13 +00:00
|
|
|
end
|
2018-07-06 10:59:48 +00:00
|
|
|
|
2018-07-10 09:44:37 +00:00
|
|
|
context 'from manifest file', :postgresql do
|
2018-07-06 10:59:48 +00:00
|
|
|
before do
|
|
|
|
first('.import_manifest').click
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows import instructions' do
|
|
|
|
expect(page).to have_content('Manifest file import')
|
|
|
|
expect(current_path).to eq new_import_manifest_path
|
|
|
|
end
|
|
|
|
end
|
2017-01-30 17:43:13 +00:00
|
|
|
end
|
2016-11-03 13:47:15 +00:00
|
|
|
end
|