blob: 0358acc8dcca7983a980008d15621fe70b96423f (
plain)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "Projects > Settings > Pipelines settings" do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :developer }
before do
sign_in(user)
project.add_role(user, role)
end
context 'for developer' do
let(:role) { :developer }
it 'to be disallowed to view' do
visit project_settings_ci_cd_path(project)
expect(page.status_code).to eq(404)
end
end
context 'for maintainer' do
let(:role) { :maintainer }
it 'be allowed to change' do
visit project_settings_ci_cd_path(project)
fill_in('Test coverage parsing', with: 'coverage_regex')
page.within '#js-general-pipeline-settings' do
click_on 'Save changes'
end
expect(page.status_code).to eq(200)
page.within '#js-general-pipeline-settings' do
expect(page).to have_button('Save changes', disabled: false)
end
expect(page).to have_field('Test coverage parsing', with: 'coverage_regex')
end
it 'updates auto_cancel_pending_pipelines' do
visit project_settings_ci_cd_path(project)
page.check('Auto-cancel redundant, pending pipelines')
page.within '#js-general-pipeline-settings' do
click_on 'Save changes'
end
expect(page.status_code).to eq(200)
page.within '#js-general-pipeline-settings' do
expect(page).to have_button('Save changes', disabled: false)
end
checkbox = find_field('project_auto_cancel_pending_pipelines')
expect(checkbox).to be_checked
end
it 'updates forward_deployment_enabled' do
visit project_settings_ci_cd_path(project)
checkbox = find_field('project_forward_deployment_enabled')
expect(checkbox).to be_checked
checkbox.set(false)
page.within '#js-general-pipeline-settings' do
click_on 'Save changes'
end
expect(page.status_code).to eq(200)
page.within '#js-general-pipeline-settings' do
expect(page).to have_button('Save changes', disabled: false)
end
checkbox = find_field('project_forward_deployment_enabled')
expect(checkbox).not_to be_checked
end
describe 'Auto DevOps' do
context 'when auto devops is turned on instance-wide' do
before do
stub_application_setting(auto_devops_enabled: true)
end
it 'auto devops is on by default and can be manually turned off' do
visit project_settings_ci_cd_path(project)
page.within '#autodevops-settings' do
expect(find_field('project_auto_devops_attributes_enabled')).to be_checked
expect(page).to have_content('instance enabled')
uncheck 'Default to Auto DevOps pipeline'
click_on 'Save changes'
end
expect(page.status_code).to eq(200)
expect(project.auto_devops).to be_present
expect(project.auto_devops).not_to be_enabled
page.within '#autodevops-settings' do
expect(find_field('project_auto_devops_attributes_enabled')).not_to be_checked
expect(page).not_to have_content('instance enabled')
end
end
end
context 'when auto devops is not turned on instance-wide' do
before do
stub_application_setting(auto_devops_enabled: false)
end
it 'auto devops is off by default and can be manually turned on' do
visit project_settings_ci_cd_path(project)
page.within '#autodevops-settings' do
expect(page).not_to have_content('instance enabled')
expect(find_field('project_auto_devops_attributes_enabled')).not_to be_checked
check 'Default to Auto DevOps pipeline'
click_on 'Save changes'
end
expect(page.status_code).to eq(200)
expect(project.auto_devops).to be_present
expect(project.auto_devops).to be_enabled
page.within '#autodevops-settings' do
expect(find_field('project_auto_devops_attributes_enabled')).to be_checked
expect(page).not_to have_content('instance enabled')
end
end
context 'when auto devops is turned on group level' do
before do
project.update!(namespace: create(:group, :auto_devops_enabled))
end
it 'renders group enabled badge' do
visit project_settings_ci_cd_path(project)
page.within '#autodevops-settings' do
expect(page).to have_content('group enabled')
expect(find_field('project_auto_devops_attributes_enabled')).to be_checked
end
end
end
context 'when auto devops is turned on group parent level' do
before do
group = create(:group, parent: create(:group, :auto_devops_enabled))
project.update!(namespace: group)
end
it 'renders group enabled badge' do
visit project_settings_ci_cd_path(project)
page.within '#autodevops-settings' do
expect(page).to have_content('group enabled')
expect(find_field('project_auto_devops_attributes_enabled')).to be_checked
end
end
end
end
end
describe 'runners registration token' do
let!(:token) { project.runners_token }
before do
visit project_settings_ci_cd_path(project)
end
it 'has a registration token' do
expect(page.find('#registration_token')).to have_content(token)
end
describe 'reload registration token' do
let(:page_token) { find('#registration_token').text }
before do
click_button 'Reset runners registration token'
end
it 'changes registration token' do
expect(page_token).not_to eq token
end
end
end
end
end
|