Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
e2d6427c
Commit
e2d6427c
authored
Aug 18, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor environments spec and remove mystery guests
parent
9e74d936
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
94 deletions
+87
-94
spec/features/projects/environments/environments_spec.rb
spec/features/projects/environments/environments_spec.rb
+87
-94
No files found.
spec/features/projects/environments/environments_spec.rb
View file @
e2d6427c
...
...
@@ -10,26 +10,23 @@ feature 'Environments page', :js do
sign_in
(
user
)
end
given!
(
:environment
)
{
}
given!
(
:deployment
)
{
}
given!
(
:action
)
{
}
before
do
visit_environments
(
project
)
end
describe
'page tabs'
do
scenario
'shows "Available" and "Stopped" tab with links'
do
it
'shows "Available" and "Stopped" tab with links'
do
visit_environments
(
project
)
expect
(
page
).
to
have_link
(
'Available'
)
expect
(
page
).
to
have_link
(
'Stopped'
)
end
describe
'with one available environment'
do
given
(
:environment
)
{
create
(
:environment
,
project:
project
,
state: :available
)
}
before
do
create
(
:environment
,
project:
project
,
state: :available
)
end
describe
'in available tab page'
do
it
'should show one environment'
do
visit
project_environments_path
(
project
,
scope:
'available'
)
visit_environments
(
project
,
scope:
'available'
)
expect
(
page
).
to
have_css
(
'.environments-container'
)
expect
(
page
.
all
(
'.environment-name'
).
length
).
to
eq
(
1
)
end
...
...
@@ -37,7 +34,8 @@ feature 'Environments page', :js do
describe
'in stopped tab page'
do
it
'should show no environments'
do
visit
project_environments_path
(
project
,
scope:
'stopped'
)
visit_environments
(
project
,
scope:
'stopped'
)
expect
(
page
).
to
have_css
(
'.environments-container'
)
expect
(
page
).
to
have_content
(
'You don\'t have any environments right now'
)
end
...
...
@@ -45,11 +43,14 @@ feature 'Environments page', :js do
end
describe
'with one stopped environment'
do
given
(
:environment
)
{
create
(
:environment
,
project:
project
,
state: :stopped
)
}
before
do
create
(
:environment
,
project:
project
,
state: :stopped
)
end
describe
'in available tab page'
do
it
'should show no environments'
do
visit
project_environments_path
(
project
,
scope:
'available'
)
visit_environments
(
project
,
scope:
'available'
)
expect
(
page
).
to
have_css
(
'.environments-container'
)
expect
(
page
).
to
have_content
(
'You don\'t have any environments right now'
)
end
...
...
@@ -57,7 +58,8 @@ feature 'Environments page', :js do
describe
'in stopped tab page'
do
it
'should show one environment'
do
visit
project_environments_path
(
project
,
scope:
'stopped'
)
visit_environments
(
project
,
scope:
'stopped'
)
expect
(
page
).
to
have_css
(
'.environments-container'
)
expect
(
page
.
all
(
'.environment-name'
).
length
).
to
eq
(
1
)
end
...
...
@@ -66,86 +68,85 @@ feature 'Environments page', :js do
end
context
'without environments'
do
scenario
'does show no environments'
do
expect
(
page
).
to
have_content
(
'You don\'t have any environments right now.'
)
before
do
visit_environments
(
project
)
end
scenario
'does show 0 as counter for environments in both tabs'
do
it
'does not show environments and counters are set to zero'
do
expect
(
page
).
to
have_content
(
'You don\'t have any environments right now.'
)
expect
(
page
.
find
(
'.js-available-environments-count'
).
text
).
to
eq
(
'0'
)
expect
(
page
.
find
(
'.js-stopped-environments-count'
).
text
).
to
eq
(
'0'
)
end
end
describe
'when showing the environment'
do
given
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
scenario
'does show environment name'
do
expect
(
page
).
to
have_link
(
environment
.
name
)
end
scenario
'does show number of available and stopped environments'
do
expect
(
page
.
find
(
'.js-available-environments-count'
).
text
).
to
eq
(
'1'
)
expect
(
page
.
find
(
'.js-stopped-environments-count'
).
text
).
to
eq
(
'0'
)
describe
'environments table'
do
given!
(
:environment
)
do
create
(
:environment
,
project:
project
,
state: :available
)
end
context
'w
ithout
deployments'
do
scenario
'does show no deployments'
do
expect
(
page
).
to
have_content
(
'No deployments yet'
)
context
'w
hen there are no
deployments'
do
before
do
visit_environments
(
project
)
end
context
'for available environment
'
do
given
(
:environment
)
{
create
(
:environment
,
project:
project
,
state: :available
)
}
it
'shows environments names and counters
'
do
expect
(
page
).
to
have_link
(
environment
.
name
)
scenario
'does not shows stop button'
do
expect
(
page
).
not_to
have_selector
(
'.stop-env-link'
)
end
expect
(
page
.
find
(
'.js-available-environments-count'
).
text
).
to
eq
(
'1'
)
expect
(
page
.
find
(
'.js-stopped-environments-count'
).
text
).
to
eq
(
'0'
)
end
context
'for stopped environment'
do
given
(
:environment
)
{
create
(
:environment
,
project:
project
,
state: :stopped
)
}
it
'does not show deployments'
do
expect
(
page
).
to
have_content
(
'No deployments yet'
)
end
scenario
'does not shows stop button'
do
expect
(
page
).
not_to
have_selector
(
'.stop-env-link'
)
end
it
'does not show stip button when environment is not stoppable'
do
expect
(
page
).
not_to
have_selector
(
'.stop-env-link'
)
end
end
context
'w
ith
deployments'
do
context
'w
hen there are
deployments'
do
given
(
:project
)
{
create
(
:project
,
:repository
)
}
given
(
:deployment
)
do
given
!
(
:deployment
)
do
create
(
:deployment
,
environment:
environment
,
sha:
project
.
commit
.
id
)
end
scenario
'does show deployment SHA'
do
expect
(
page
).
to
have_link
(
deployment
.
short_sha
)
end
scenario
'does show deployment internal id'
do
it
'shows deployment SHA and internal ID'
do
visit_environments
(
project
)
expect
(
page
).
to
have_link
(
deployment
.
short_sha
)
expect
(
page
).
to
have_content
(
deployment
.
iid
)
end
context
'w
ith build and manual actions
'
do
given
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
given
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
context
'w
hen builds and manual actions are present
'
do
given
!
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
given
!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
given
(
:action
)
do
given
!
(
:action
)
do
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
,
name:
'deploy to production'
)
end
given
(
:deployment
)
do
given
!
(
:deployment
)
do
create
(
:deployment
,
environment:
environment
,
deployable:
build
,
sha:
project
.
commit
.
id
)
end
scenario
'does show a play button'
do
before
do
visit_environments
(
project
)
end
it
'shows a play button'
do
find
(
'.js-dropdown-play-icon-container'
).
click
expect
(
page
).
to
have_content
(
action
.
name
.
humanize
)
end
scenario
'does allow to play
manual action'
,
js:
true
do
it
'allows to play a
manual action'
,
js:
true
do
expect
(
action
).
to
be_manual
find
(
'.js-dropdown-play-icon-container'
).
click
...
...
@@ -155,19 +156,19 @@ feature 'Environments page', :js do
.
not_to
change
{
Ci
::
Pipeline
.
count
}
end
scenario
'does show
build name and id'
do
it
'shows
build name and id'
do
expect
(
page
).
to
have_link
(
"
#{
build
.
name
}
#
#{
build
.
id
}
"
)
end
scenario
'does not show
stop button'
do
it
'shows a
stop button'
do
expect
(
page
).
not_to
have_selector
(
'.stop-env-link'
)
end
scenario
'does not show external link button'
do
it
'does not show external link button'
do
expect
(
page
).
not_to
have_css
(
'external-url'
)
end
scenario
'does not show terminal button'
do
it
'does not show terminal button'
do
expect
(
page
).
not_to
have_terminal_button
end
...
...
@@ -176,7 +177,7 @@ feature 'Environments page', :js do
given
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
given
(
:deployment
)
{
create
(
:deployment
,
environment:
environment
,
deployable:
build
)
}
scenario
'does show
an external link button'
do
it
'shows
an external link button'
do
expect
(
page
).
to
have_link
(
nil
,
href:
environment
.
external_url
)
end
end
...
...
@@ -192,34 +193,34 @@ feature 'Environments page', :js do
on_stop:
'close_app'
)
end
scenario
'does show
stop button'
do
it
'shows a
stop button'
do
expect
(
page
).
to
have_selector
(
'.stop-env-link'
)
end
context
'
for
reporter'
do
context
'
when user is a
reporter'
do
let
(
:role
)
{
:reporter
}
scenario
'does not show stop button'
do
it
'does not show stop button'
do
expect
(
page
).
not_to
have_selector
(
'.stop-env-link'
)
end
end
end
context
'w
ith terminal
'
do
context
'w
hen kubernetes terminal is available
'
do
let
(
:project
)
{
create
(
:kubernetes_project
,
:test_repo
)
}
context
'for project master'
do
let
(
:role
)
{
:master
}
scenario
'it
shows the terminal button'
do
it
'
shows the terminal button'
do
expect
(
page
).
to
have_terminal_button
end
end
context
'
for
developer'
do
context
'
when user is a
developer'
do
let
(
:role
)
{
:developer
}
scenario
'does not show terminal button'
do
it
'does not show terminal button'
do
expect
(
page
).
not_to
have_terminal_button
end
end
...
...
@@ -228,49 +229,41 @@ feature 'Environments page', :js do
end
end
scenario
'does have a New environment button'
do
it
'does have a new environment button'
do
visit_environments
(
project
)
expect
(
page
).
to
have_link
(
'New environment'
)
end
describe
'
when
creating a new environment'
do
describe
'creating a new environment'
do
before
do
visit_environments
(
project
)
end
context
'when logged as developer'
do
before
do
within
(
".top-area"
)
do
click_link
'New environment'
end
end
context
'user is a developer'
do
given
(
:role
)
{
:developer
}
context
'for valid name'
do
before
do
fill_in
(
'Name'
,
with:
'production'
)
click_on
'Save'
end
scenario
'developer creates a new environment with a valid name'
do
within
(
".top-area"
)
{
click_link
'New environment'
}
fill_in
(
'Name'
,
with:
'production'
)
click_on
'Save'
scenario
'does create a new pipeline'
do
expect
(
page
).
to
have_content
(
'production'
)
end
expect
(
page
).
to
have_content
(
'production'
)
end
context
'for invalid name'
do
before
do
fill_in
(
'Name'
,
with:
'name,with,commas'
)
click_on
'Save'
end
scenario
'developer creates a new environmetn with invalid name'
do
within
(
".top-area"
)
{
click_link
'New environment'
}
fill_in
(
'Name'
,
with:
'name,with,commas'
)
click_on
'Save'
scenario
'does show errors'
do
expect
(
page
).
to
have_content
(
'Name can contain only letters'
)
end
expect
(
page
).
to
have_content
(
'Name can contain only letters'
)
end
end
context
'
when logged as
reporter'
do
context
'
user is a
reporter'
do
given
(
:role
)
{
:reporter
}
scenario
'
does not have a New environment link
'
do
scenario
'
reporters tries to create a new environment
'
do
expect
(
page
).
not_to
have_link
(
'New environment'
)
end
end
...
...
@@ -280,7 +273,7 @@ feature 'Environments page', :js do
have_link
(
nil
,
href:
terminal_project_environment_path
(
project
,
environment
))
end
def
visit_environments
(
project
)
visit
project_environments_path
(
project
)
def
visit_environments
(
project
,
**
opts
)
visit
project_environments_path
(
project
,
**
opts
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment