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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
require 'spec_helper'
describe "Admin::Projects", feature: true do
include Select2Helper
let(:user) { create :user }
let!(:project) { create(:project) }
let!(:current_user) do
gitlab_sign_in :admin
end
describe "GET /admin/projects" do
let!(:archived_project) { create :project, :public, :archived }
before do
visit admin_projects_path
end
it "is ok" do
expect(current_path).to eq(admin_projects_path)
end
it 'renders projects list without archived project' do
expect(page).to have_content(project.name)
expect(page).not_to have_content(archived_project.name)
end
it 'renders all projects', js: true do
find(:css, '#sort-projects-dropdown').click
click_link 'Show archived projects'
expect(page).to have_content(project.name)
expect(page).to have_content(archived_project.name)
expect(page).to have_xpath("//span[@class='label label-warning']", text: 'archived')
end
end
describe "GET /admin/projects/:namespace_id/:id" do
before do
visit admin_projects_path
click_link "#{project.name}"
end
it do
expect(current_path).to eq admin_project_path(project)
end
it "has project info" do
expect(page).to have_content(project.path)
expect(page).to have_content(project.name)
expect(page).to have_content(project.name_with_namespace)
expect(page).to have_content(project.creator.name)
end
end
describe 'transfer project' do
before do
create(:group, name: 'Web')
allow_any_instance_of(Projects::TransferService)
.to receive(:move_uploads_to_new_namespace).and_return(true)
end
it 'transfers project to group web', js: true do
visit admin_project_path(project)
click_button 'Search for Namespace'
click_link 'group: web'
click_button 'Transfer'
expect(page).to have_content("Web / #{project.name}")
expect(page).to have_content('Namespace: Web')
end
end
describe 'add admin himself to a project' do
before do
project.team << [user, :master]
end
it 'adds admin a to a project as developer', js: true do
visit project_project_members_path(project)
page.within '.users-project-form' do
select2(current_user.id, from: '#user_ids', multiple: true)
select 'Developer', from: 'access_level'
end
click_button 'Add to project'
page.within '.content-list' do
expect(page).to have_content(current_user.name)
expect(page).to have_content('Developer')
end
end
end
describe 'admin remove himself from a project' do
before do
project.team << [user, :master]
project.team << [current_user, :developer]
end
it 'removes admin from the project' do
visit project_project_members_path(project)
page.within '.content-list' do
expect(page).to have_content(current_user.name)
expect(page).to have_content('Developer')
end
find(:css, '.content-list li', text: current_user.name).find(:css, 'a.btn-remove').click
expect(page).not_to have_selector(:css, '.content-list')
end
end
end
|