2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-21 06:45:43 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'User creates a project', :js do
|
2017-06-21 06:45:43 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
create(:personal_key, user: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a new project' do
|
2017-11-09 09:59:11 -05:00
|
|
|
visit(new_project_path)
|
|
|
|
|
2018-09-08 02:03:00 -04:00
|
|
|
fill_in(:project_name, with: 'Empty')
|
2017-06-21 06:45:43 -04:00
|
|
|
|
|
|
|
page.within('#content-body') do
|
|
|
|
click_button('Create project')
|
|
|
|
end
|
|
|
|
|
|
|
|
project = Project.last
|
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
expect(current_path).to eq(project_path(project))
|
2017-06-21 06:45:43 -04: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 09:59:11 -05:00
|
|
|
|
2019-07-24 05:20:54 -04:00
|
|
|
context 'in a subgroup they do not own' do
|
2017-11-09 09:59:11 -05: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)
|
|
|
|
|
2018-09-08 02:03:00 -04:00
|
|
|
fill_in :project_name, with: 'A Subgroup Project'
|
2017-11-09 09:59:11 -05: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 02:03:00 -04:00
|
|
|
expect(page).to have_content("Project 'A Subgroup Project' was successfully created")
|
2017-11-09 09:59:11 -05:00
|
|
|
|
|
|
|
project = Project.last
|
|
|
|
|
|
|
|
expect(project.namespace).to eq(subgroup)
|
|
|
|
end
|
|
|
|
end
|
2019-04-05 14:49:46 -04: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)
|
|
|
|
|
|
|
|
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 06:45:43 -04:00
|
|
|
end
|