2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-21 10:45:43 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 18:08:28 +00:00
|
|
|
RSpec.describe 'User creates a project', :js do
|
2017-06-21 10:45:43 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2021-08-30 06:09:35 +00:00
|
|
|
stub_feature_flags(paginatable_namespace_drop_down_for_project_creation: false)
|
2017-06-21 10:45:43 +00:00
|
|
|
sign_in(user)
|
|
|
|
create(:personal_key, user: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a new project' do
|
2017-11-09 14:59:11 +00:00
|
|
|
visit(new_project_path)
|
|
|
|
|
2021-10-21 09:09:48 +00:00
|
|
|
click_link 'Create blank project'
|
2018-09-08 06:03:00 +00:00
|
|
|
fill_in(:project_name, with: 'Empty')
|
2017-06-21 10:45:43 +00:00
|
|
|
|
2021-02-06 00:09:54 +00:00
|
|
|
expect(page).to have_checked_field 'Initialize repository with a README'
|
|
|
|
uncheck 'Initialize repository with a README'
|
|
|
|
|
2017-06-21 10:45:43 +00:00
|
|
|
page.within('#content-body') do
|
|
|
|
click_button('Create project')
|
|
|
|
end
|
|
|
|
|
|
|
|
project = Project.last
|
|
|
|
|
2017-06-29 17:06:35 +00:00
|
|
|
expect(current_path).to eq(project_path(project))
|
2017-06-21 10:45:43 +00:00
|
|
|
expect(page).to have_content('Empty')
|
|
|
|
expect(page).to have_content('git init')
|
|
|
|
expect(page).to have_content('git remote')
|
|
|
|
expect(page).to have_content(project.url_to_repo)
|
|
|
|
end
|
2017-11-09 14:59:11 +00:00
|
|
|
|
2021-10-07 21:11:49 +00:00
|
|
|
it 'creates a new project that is not blank' do
|
|
|
|
stub_experiments(new_project_sast_enabled: 'candidate')
|
|
|
|
|
|
|
|
visit(new_project_path)
|
|
|
|
|
2021-10-21 09:09:48 +00:00
|
|
|
click_link 'Create blank project'
|
2021-10-07 21:11:49 +00:00
|
|
|
fill_in(:project_name, with: 'With initial commits')
|
|
|
|
|
|
|
|
expect(page).to have_checked_field 'Initialize repository with a README'
|
|
|
|
expect(page).to have_checked_field 'Enable Static Application Security Testing (SAST)'
|
|
|
|
|
|
|
|
page.within('#content-body') do
|
2021-12-08 21:10:18 +00:00
|
|
|
click_button('Create project')
|
|
|
|
end
|
|
|
|
|
|
|
|
project = Project.last
|
|
|
|
|
|
|
|
expect(current_path).to eq(project_path(project))
|
|
|
|
expect(page).to have_content('With initial commits')
|
|
|
|
expect(page).to have_content('Configure SAST in `.gitlab-ci.yml`, creating this file if it does not already exist')
|
|
|
|
expect(page).to have_content('README.md Initial commit')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows creating a new project when the new_project_sast_enabled is assigned the unchecked candidate' do
|
|
|
|
stub_experiments(new_project_sast_enabled: 'unchecked_candidate')
|
|
|
|
|
|
|
|
visit(new_project_path)
|
|
|
|
|
|
|
|
click_link 'Create blank project'
|
|
|
|
fill_in(:project_name, with: 'With initial commits')
|
|
|
|
|
|
|
|
expect(page).to have_checked_field 'Initialize repository with a README'
|
|
|
|
expect(page).to have_unchecked_field 'Enable Static Application Security Testing (SAST)'
|
|
|
|
|
|
|
|
check 'Enable Static Application Security Testing (SAST)'
|
|
|
|
|
|
|
|
page.within('#content-body') do
|
2021-10-07 21:11:49 +00:00
|
|
|
click_button('Create project')
|
|
|
|
end
|
|
|
|
|
|
|
|
project = Project.last
|
|
|
|
|
|
|
|
expect(current_path).to eq(project_path(project))
|
|
|
|
expect(page).to have_content('With initial commits')
|
|
|
|
expect(page).to have_content('Configure SAST in `.gitlab-ci.yml`, creating this file if it does not already exist')
|
|
|
|
expect(page).to have_content('README.md Initial commit')
|
|
|
|
end
|
|
|
|
|
2019-07-24 09:20:54 +00:00
|
|
|
context 'in a subgroup they do not own' do
|
2017-11-09 14:59:11 +00:00
|
|
|
let(:parent) { create(:group) }
|
|
|
|
let!(:subgroup) { create(:group, parent: parent) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
parent.add_owner(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a new project' do
|
|
|
|
visit(new_project_path)
|
|
|
|
|
2021-10-21 09:09:48 +00:00
|
|
|
click_link 'Create blank project'
|
2018-09-08 06:03:00 +00:00
|
|
|
fill_in :project_name, with: 'A Subgroup Project'
|
2017-11-09 14:59:11 +00:00
|
|
|
fill_in :project_path, with: 'a-subgroup-project'
|
|
|
|
|
|
|
|
page.find('.js-select-namespace').click
|
|
|
|
page.find("div[role='option']", text: subgroup.full_path).click
|
|
|
|
|
|
|
|
page.within('#content-body') do
|
|
|
|
click_button('Create project')
|
|
|
|
end
|
|
|
|
|
2018-09-08 06:03:00 +00:00
|
|
|
expect(page).to have_content("Project 'A Subgroup Project' was successfully created")
|
2017-11-09 14:59:11 +00:00
|
|
|
|
|
|
|
project = Project.last
|
|
|
|
|
|
|
|
expect(project.namespace).to eq(subgroup)
|
|
|
|
end
|
|
|
|
end
|
2019-04-05 18:49:46 +00:00
|
|
|
|
|
|
|
context 'in a group with DEVELOPER_MAINTAINER_PROJECT_ACCESS project_creation_level' do
|
|
|
|
let(:group) { create(:group, project_creation_level: ::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_developer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a new project' do
|
|
|
|
visit(new_project_path)
|
|
|
|
|
2021-10-21 09:09:48 +00:00
|
|
|
click_link 'Create blank project'
|
2019-04-05 18:49:46 +00:00
|
|
|
fill_in :project_name, with: 'a-new-project'
|
|
|
|
fill_in :project_path, with: 'a-new-project'
|
|
|
|
|
|
|
|
page.find('.js-select-namespace').click
|
|
|
|
page.find("div[role='option']", text: group.full_path).click
|
|
|
|
|
|
|
|
page.within('#content-body') do
|
|
|
|
click_button('Create project')
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content("Project 'a-new-project' was successfully created")
|
|
|
|
|
|
|
|
project = Project.find_by(name: 'a-new-project')
|
|
|
|
expect(project.namespace).to eq(group)
|
|
|
|
end
|
|
|
|
end
|
2017-06-21 10:45:43 +00:00
|
|
|
end
|