1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Projects > Settings > User transfers a project', :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, namespace: user.namespace) }
let(:group) { create(:group) }
before do
group.add_owner(user)
sign_in(user)
end
def transfer_project(project, group, confirm: true)
visit edit_project_path(project)
page.within('.js-project-transfer-form') do
page.find('.select2-container').click
end
page.find("div[role='option']", text: group.full_name).click
click_button('Transfer project')
return unless confirm
fill_in 'confirm_name_input', with: project.name
click_button 'Confirm'
wait_for_requests
end
it 'focuses on the confirmation field' do
transfer_project(project, group, confirm: false)
expect(page).to have_selector '#confirm_name_input:focus'
end
it 'allows transferring a project to a group' do
old_path = project_path(project)
transfer_project(project, group)
new_path = namespace_project_path(group, project)
expect(project.reload.namespace).to eq(group)
visit new_path
wait_for_requests
expect(current_path).to eq(new_path)
expect(find('.breadcrumbs')).to have_content(project.name)
visit old_path
wait_for_requests
expect(current_path).to eq(new_path)
expect(find('.breadcrumbs')).to have_content(project.name)
end
context 'and a new project is added with the same path' do
it 'overrides the redirect' do
old_path = project_path(project)
project_path = project.path
transfer_project(project, group)
new_project = create(:project, namespace: user.namespace, path: project_path)
visit old_path
expect(current_path).to eq(old_path)
expect(find('.breadcrumbs')).to have_content(new_project.name)
end
end
context 'when nested groups are available' do
it 'allows transferring a project to a subgroup' do
subgroup = create(:group, parent: group)
transfer_project(project, subgroup)
expect(project.reload.namespace).to eq(subgroup)
end
end
end
|