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

174 lines
5.9 KiB
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe 'Edit Project Settings' do
2017-08-17 22:00:37 +05:30
include Select2Helper
2016-09-13 17:45:13 +05:30
let(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project, namespace: user.namespace, path: 'gitlab', name: 'sample') }
2016-09-13 17:45:13 +05:30
before do
2017-09-10 17:25:29 +05:30
sign_in(user)
2016-09-13 17:45:13 +05:30
end
2017-08-17 22:00:37 +05:30
describe 'Project settings section', js: true do
2016-09-13 17:45:13 +05:30
it 'shows errors for invalid project name' do
2017-09-10 17:25:29 +05:30
visit edit_project_path(project)
2016-09-13 17:45:13 +05:30
fill_in 'project_name_edit', with: 'foo&bar'
2017-09-10 17:25:29 +05:30
page.within('.general-settings') do
click_button 'Save changes'
end
2016-09-13 17:45:13 +05:30
expect(page).to have_field 'project_name_edit', with: 'foo&bar'
2017-08-17 22:00:37 +05:30
expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
2016-09-13 17:45:13 +05:30
expect(page).to have_button 'Save changes'
end
2017-08-17 22:00:37 +05:30
it 'shows a successful notice when the project is updated' do
2017-09-10 17:25:29 +05:30
visit edit_project_path(project)
2017-08-17 22:00:37 +05:30
fill_in 'project_name_edit', with: 'hello world'
2017-09-10 17:25:29 +05:30
page.within('.general-settings') do
click_button 'Save changes'
end
2017-08-17 22:00:37 +05:30
expect(page).to have_content "Project 'hello world' was successfully updated."
end
end
describe 'Rename repository section' do
context 'with invalid characters' do
it 'shows errors for invalid project path/name' do
rename_project(project, name: 'foo&bar', path: 'foo&bar')
expect(page).to have_field 'Project name', with: 'foo&bar'
expect(page).to have_field 'Path', with: 'foo&bar'
expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
expect(page).to have_content "Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'"
end
end
context 'when changing project name' do
it 'renames the repository' do
rename_project(project, name: 'bar')
expect(find('h1.title')).to have_content(project.name)
end
context 'with emojis' do
it 'shows error for invalid project name' do
rename_project(project, name: '🚀 foo bar ☁️')
expect(page).to have_field 'Project name', with: '🚀 foo bar ☁️'
expect(page).not_to have_content "Name can contain only letters, digits, emojis '_', '.', dash and space. It must start with letter, digit, emoji or '_'."
end
end
end
context 'when changing project path' do
2017-09-10 17:25:29 +05:30
let(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') }
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
before(:context) do
TestEnv.clean_test_path
end
after(:example) do
TestEnv.clean_test_path
end
2017-08-17 22:00:37 +05:30
specify 'the project is accessible via the new path' do
rename_project(project, path: 'bar')
new_path = namespace_project_path(project.namespace, 'bar')
visit new_path
expect(current_path).to eq(new_path)
expect(find('h1.title')).to have_content(project.name)
end
2016-09-13 17:45:13 +05:30
2017-08-17 22:00:37 +05:30
specify 'the project is accessible via a redirect from the old path' do
2017-09-10 17:25:29 +05:30
old_path = project_path(project)
2017-08-17 22:00:37 +05:30
rename_project(project, path: 'bar')
new_path = namespace_project_path(project.namespace, 'bar')
visit old_path
expect(current_path).to eq(new_path)
expect(find('h1.title')).to have_content(project.name)
end
2016-09-13 17:45:13 +05:30
2017-08-17 22:00:37 +05:30
context 'and a new project is added with the same path' do
it 'overrides the redirect' do
2017-09-10 17:25:29 +05:30
old_path = project_path(project)
2017-08-17 22:00:37 +05:30
rename_project(project, path: 'bar')
2017-09-10 17:25:29 +05:30
new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz')
2017-08-17 22:00:37 +05:30
visit old_path
expect(current_path).to eq(old_path)
expect(find('h1.title')).to have_content(new_project.name)
end
end
end
end
describe 'Transfer project section', js: true do
2017-09-10 17:25:29 +05:30
let!(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') }
2017-08-17 22:00:37 +05:30
let!(:group) { create(:group) }
2017-09-10 17:25:29 +05:30
before(:context) do
TestEnv.clean_test_path
end
before(:example) do
group.add_owner(user)
end
after(:example) do
TestEnv.clean_test_path
end
2017-08-17 22:00:37 +05:30
specify 'the project is accessible via the new path' do
transfer_project(project, group)
new_path = namespace_project_path(group, project)
visit new_path
expect(current_path).to eq(new_path)
expect(find('h1.title')).to have_content(project.name)
end
specify 'the project is accessible via a redirect from the old path' do
2017-09-10 17:25:29 +05:30
old_path = project_path(project)
2017-08-17 22:00:37 +05:30
transfer_project(project, group)
new_path = namespace_project_path(group, project)
visit old_path
expect(current_path).to eq(new_path)
expect(find('h1.title')).to have_content(project.name)
end
2016-09-13 17:45:13 +05:30
2017-08-17 22:00:37 +05:30
context 'and a new project is added with the same path' do
it 'overrides the redirect' do
2017-09-10 17:25:29 +05:30
old_path = project_path(project)
2017-08-17 22:00:37 +05:30
transfer_project(project, group)
2017-09-10 17:25:29 +05:30
new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz')
2017-08-17 22:00:37 +05:30
visit old_path
expect(current_path).to eq(old_path)
expect(find('h1.title')).to have_content(new_project.name)
end
2016-09-13 17:45:13 +05:30
end
end
end
2017-08-17 22:00:37 +05:30
def rename_project(project, name: nil, path: nil)
2017-09-10 17:25:29 +05:30
visit edit_project_path(project)
2017-08-17 22:00:37 +05:30
fill_in('project_name', with: name) if name
fill_in('Path', with: path) if path
click_button('Rename project')
wait_for_edit_project_page_reload
project.reload
end
def transfer_project(project, namespace)
2017-09-10 17:25:29 +05:30
visit edit_project_path(project)
2017-08-17 22:00:37 +05:30
select2(namespace.id, from: '#new_namespace_id')
click_button('Transfer project')
confirm_transfer_modal
wait_for_edit_project_page_reload
project.reload
end
def confirm_transfer_modal
fill_in('confirm_name_input', with: project.path)
click_button 'Confirm'
end
def wait_for_edit_project_page_reload
expect(find('.project-edit-container')).to have_content('Rename repository')
end