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
|
require 'spec_helper'
describe 'Environments' do
include GitlabRoutingHelper
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
let(:role) { :developer }
before do
login_as(user)
project.team << [user, role]
end
describe 'GET /:project/environments' do
subject { visit namespace_project_environments_path(project.namespace, project) }
context 'without environments' do
it 'does show no environments' do
subject
expect(page).to have_content('No environments to show')
end
end
context 'with environments' do
let!(:environment) { create(:environment, project: project) }
it 'does show environment name' do
subject
expect(page).to have_link(environment.name)
end
context 'without deployments' do
it 'does show no deployments' do
subject
expect(page).to have_content('No deployments yet')
end
end
context 'with deployments' do
let!(:deployment) { create(:deployment, environment: environment) }
it 'does show deployment SHA' do
subject
expect(page).to have_link(deployment.short_sha)
end
end
end
it 'does have a New environment button' do
subject
expect(page).to have_link('New environment')
end
end
describe 'GET /:project/environments/:id' do
let(:environment) { create(:environment, project: project) }
subject { visit namespace_project_environment_path(project.namespace, project, environment) }
context 'without deployments' do
it 'does show no deployments' do
subject
expect(page).to have_content('No deployments for')
end
end
context 'with deployments' do
let!(:deployment) { create(:deployment, environment: environment) }
before { subject }
it 'does show deployment SHA' do
expect(page).to have_link(deployment.short_sha)
end
it 'does not show a retry button for deployment without build' do
expect(page).not_to have_link('Retry')
end
context 'with build' do
let(:build) { create(:ci_build, project: project) }
let(:deployment) { create(:deployment, environment: environment, deployable: build) }
it 'does show build name' do
expect(page).to have_link("#{build.name} (##{build.id})")
end
it 'does show retry button' do
expect(page).to have_link('Retry')
end
end
end
end
describe 'POST /:project/environments' do
before { visit namespace_project_environments_path(project.namespace, project) }
context 'when logged as developer' do
before { click_link 'New environment' }
context 'for valid name' do
before do
fill_in('Name', with: 'production')
click_on 'Create environment'
end
it 'does create a new pipeline' do
expect(page).to have_content('production')
end
end
context 'for invalid name' do
before do
fill_in('Name', with: 'name with spaces')
click_on 'Create environment'
end
it { expect(page).to have_content('Name can contain only letters') }
end
end
context 'when logged as reporter' do
let(:role) { :reporter }
it 'does not have a New environment link' do
expect(page).not_to have_link('New environment')
end
end
end
describe 'DELETE /:project/environments/:id' do
let(:environment) { create(:environment, project: project) }
before { visit namespace_project_environment_path(project.namespace, project, environment) }
context 'when logged as master' do
let(:role) { :master }
before { click_link 'Destroy' }
it 'does not have environment' do
expect(page).not_to have_link(environment.name)
end
end
context 'when logged as developer' do
let(:role) { :developer }
it 'does not have a Destroy link' do
expect(page).not_to have_link('Destroy')
end
end
end
end
|