debian-mirror-gitlab/spec/features/projects/new_project_spec.rb

153 lines
3.9 KiB
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
require 'spec_helper'
2016-11-24 13:41:30 +05:30
2017-09-10 17:25:29 +05:30
feature 'New project' do
2017-08-17 22:00:37 +05:30
let(:user) { create(:admin) }
2016-11-24 13:41:30 +05:30
2017-08-17 22:00:37 +05:30
before do
2017-09-10 17:25:29 +05:30
sign_in(user)
2017-08-17 22:00:37 +05:30
end
2016-11-24 13:41:30 +05:30
2017-09-10 17:25:29 +05:30
it 'shows "New project" page' do
visit new_project_path
expect(page).to have_content('Project path')
expect(page).to have_content('Project name')
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
context 'Visibility level selector' do
2016-11-24 13:41:30 +05:30
Gitlab::VisibilityLevel.options.each do |key, level|
it "sets selector to #{key}" do
stub_application_setting(default_project_visibility: level)
visit new_project_path
expect(find_field("project_visibility_level_#{level}")).to be_checked
end
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
it "saves visibility level #{level} on validation error" do
2017-08-17 22:00:37 +05:30
visit new_project_path
2017-09-10 17:25:29 +05:30
choose(s_(key))
2017-08-17 22:00:37 +05:30
click_button('Create project')
expect(find_field("project_visibility_level_#{level}")).to be_checked
end
end
end
2017-09-10 17:25:29 +05:30
context 'Namespace selector' do
context 'with user namespace' do
2017-08-17 22:00:37 +05:30
before do
visit new_project_path
end
2017-09-10 17:25:29 +05:30
it 'selects the user namespace' do
namespace = find('#project_namespace_id')
2017-08-17 22:00:37 +05:30
expect(namespace.text).to eq user.username
end
end
2017-09-10 17:25:29 +05:30
context 'with group namespace' do
2017-08-17 22:00:37 +05:30
let(:group) { create(:group, :private, owner: user) }
before do
group.add_owner(user)
visit new_project_path(namespace_id: group.id)
end
2017-09-10 17:25:29 +05:30
it 'selects the group namespace' do
namespace = find('#project_namespace_id option[selected]')
2017-08-17 22:00:37 +05:30
expect(namespace.text).to eq group.name
end
2017-09-10 17:25:29 +05:30
context 'on validation error' do
2017-08-17 22:00:37 +05:30
before do
fill_in('project_path', with: 'private-group-project')
choose('Internal')
click_button('Create project')
expect(page).to have_css '.project-edit-errors .alert.alert-danger'
end
2017-09-10 17:25:29 +05:30
it 'selects the group namespace' do
namespace = find('#project_namespace_id option[selected]')
2017-08-17 22:00:37 +05:30
expect(namespace.text).to eq group.name
end
end
end
2017-09-10 17:25:29 +05:30
context 'with subgroup namespace' do
2017-08-17 22:00:37 +05:30
let(:group) { create(:group, :private, owner: user) }
let(:subgroup) { create(:group, parent: group) }
before do
group.add_master(user)
visit new_project_path(namespace_id: subgroup.id)
end
2017-09-10 17:25:29 +05:30
it 'selects the group namespace' do
namespace = find('#project_namespace_id option[selected]')
2017-08-17 22:00:37 +05:30
expect(namespace.text).to eq subgroup.full_path
end
end
end
context 'Import project options' do
before do
visit new_project_path
end
2017-09-10 17:25:29 +05:30
context 'from git repository url' do
before do
first('.import_git').click
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-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(git_import_instructions).to be_visible
expect(git_import_instructions).to have_content 'Git repository URL'
end
end
context 'from GitHub' do
before do
first('.import_github').click
end
it 'shows import instructions' do
expect(page).to have_content('Import Projects from GitHub')
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
2016-11-24 13:41:30 +05:30
end
end
end