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
Tatuya Kamada
gitlab-ce
Commits
34e19b9b
Commit
34e19b9b
authored
Oct 17, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs
parent
e9880722
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
57 deletions
+43
-57
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+1
-1
spec/features/environments_spec.rb
spec/features/environments_spec.rb
+2
-40
spec/features/merge_requests/merge_when_build_succeeds_spec.rb
...features/merge_requests/merge_when_build_succeeds_spec.rb
+0
-9
spec/features/merge_requests/widget_deployments_spec.rb
spec/features/merge_requests/widget_deployments_spec.rb
+40
-7
No files found.
app/controllers/projects/environments_controller.rb
View file @
34e19b9b
class
Projects::EnvironmentsController
<
Projects
::
ApplicationController
class
Projects::EnvironmentsController
<
Projects
::
ApplicationController
layout
'project'
layout
'project'
before_action
:authorize_read_environment!
before_action
:authorize_read_environment!
before_action
:authorize_create_environment!
,
only:
[
:new
,
:create
,
:stop
]
before_action
:authorize_create_environment!
,
only:
[
:new
,
:create
]
before_action
:authorize_create_deployment!
,
only:
[
:stop
]
before_action
:authorize_create_deployment!
,
only:
[
:stop
]
before_action
:authorize_update_environment!
,
only:
[
:edit
,
:update
]
before_action
:authorize_update_environment!
,
only:
[
:edit
,
:update
]
before_action
:environment
,
only:
[
:show
,
:edit
,
:update
,
:stop
]
before_action
:environment
,
only:
[
:show
,
:edit
,
:update
,
:stop
]
...
...
spec/features/environments_spec.rb
View file @
34e19b9b
...
@@ -119,7 +119,7 @@ feature 'Environments', feature: true do
...
@@ -119,7 +119,7 @@ feature 'Environments', feature: true do
expect
(
page
).
to
have_selector
(
'.close-env-link'
)
expect
(
page
).
to
have_selector
(
'.close-env-link'
)
end
end
scenario
'
does allow to stop environment
'
do
scenario
'
starts build when stop button clicked
'
do
first
(
'.close-env-link'
).
click
first
(
'.close-env-link'
).
click
expect
(
page
).
to
have_content
(
'close_app'
)
expect
(
page
).
to
have_content
(
'close_app'
)
...
@@ -217,7 +217,7 @@ feature 'Environments', feature: true do
...
@@ -217,7 +217,7 @@ feature 'Environments', feature: true do
expect
(
page
).
to
have_link
(
'Stop'
)
expect
(
page
).
to
have_link
(
'Stop'
)
end
end
scenario
'
does allow to stop environment
'
do
scenario
'
scenario '
does
allow
to
stop
environment
' do
'
do
click_link
(
'Stop'
)
click_link
(
'Stop'
)
expect
(
page
).
to
have_content
(
'close_app'
)
expect
(
page
).
to
have_content
(
'close_app'
)
...
@@ -277,42 +277,4 @@ feature 'Environments', feature: true do
...
@@ -277,42 +277,4 @@ feature 'Environments', feature: true do
end
end
end
end
end
end
describe
'when deleting existing environment'
do
given
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
before
do
visit
namespace_project_environment_path
(
project
.
namespace
,
project
,
environment
)
end
context
'when logged as master'
do
given
(
:role
)
{
:master
}
scenario
'does not have a Close link'
do
expect
(
page
).
not_to
have_link
(
'Close'
)
end
context
'when environment is opened and can be closed'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let!
(
:deployment
)
do
create
(
:deployment
,
environment:
environment
,
sha:
project
.
commit
(
'master'
).
id
)
end
scenario
'does have a Close link'
do
# TODO: Add missing validation. In order to have Close link
# this must be true: last_deployment.try(:close_action)
end
end
end
context
'when logged as developer'
do
given
(
:role
)
{
:developer
}
scenario
'does not have a Close link'
do
expect
(
page
).
not_to
have_link
(
'Close'
)
end
end
end
end
end
spec/features/merge_requests/merge_when_build_succeeds_spec.rb
View file @
34e19b9b
...
@@ -102,15 +102,6 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
...
@@ -102,15 +102,6 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
end
end
end
end
context
'Has Environment'
do
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
it
'does show link to close the environment'
do
# TODO add test to verify if the button is visible when this condition
# is met: if environment.closeable?
end
end
def
visit_merge_request
(
merge_request
)
def
visit_merge_request
(
merge_request
)
visit
namespace_project_merge_request_path
(
merge_request
.
project
.
namespace
,
merge_request
.
project
,
merge_request
)
visit
namespace_project_merge_request_path
(
merge_request
.
project
.
namespace
,
merge_request
.
project
,
merge_request
)
end
end
...
...
spec/features/merge_requests/widget_deployments_spec.rb
View file @
34e19b9b
...
@@ -4,23 +4,56 @@ feature 'Widget Deployments Header', feature: true, js: true do
...
@@ -4,23 +4,56 @@ feature 'Widget Deployments Header', feature: true, js: true do
include
WaitForAjax
include
WaitForAjax
describe
'when deployed to an environment'
do
describe
'when deployed to an environment'
do
let
(
:project
)
{
merge_request
.
target_project
}
given
(
:user
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
:merged
)
}
given
(
:project
)
{
merge_request
.
target_project
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
given
(
:merge_request
)
{
create
(
:merge_request
,
:merged
)
}
let!
(
:deployment
)
do
given
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
given
(
:role
)
{
:developer
}
given!
(
:deployment
)
do
create
(
:deployment
,
environment:
environment
,
sha:
project
.
commit
(
'master'
).
id
)
create
(
:deployment
,
environment:
environment
,
sha:
project
.
commit
(
'master'
).
id
)
end
end
given!
(
:manual
)
{
}
before
do
background
do
login_as
:admin
login_as
(
user
)
project
.
team
<<
[
user
,
role
]
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
end
it
'displays that the environment is deployed'
do
scenario
'displays that the environment is deployed'
do
wait_for_ajax
wait_for_ajax
expect
(
page
).
to
have_content
(
"Deployed to
#{
environment
.
name
}
"
)
expect
(
page
).
to
have_content
(
"Deployed to
#{
environment
.
name
}
"
)
expect
(
find
(
'.ci_widget > span > span'
)[
'data-title'
]).
to
eq
(
deployment
.
created_at
.
to_time
.
in_time_zone
.
to_s
(
:medium
))
expect
(
find
(
'.ci_widget > span > span'
)[
'data-title'
]).
to
eq
(
deployment
.
created_at
.
to_time
.
in_time_zone
.
to_s
(
:medium
))
end
end
context
'with stop action'
do
given
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
given
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
given
(
:manual
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
,
name:
'close_app'
)
}
given
(
:deployment
)
{
create
(
:deployment
,
environment:
environment
,
deployable:
build
,
on_stop:
'close_app'
)
}
background
do
wait_for_ajax
end
scenario
'does show stop button'
do
expect
(
page
).
to
have_link
(
'Stop environment'
)
end
scenario
'does start build when stop button clicked'
do
click_link
(
'Stop environment'
)
expect
(
page
).
to
have_content
(
'close_app'
)
end
context
'for reporter'
do
given
(
:role
)
{
:reporter
}
scenario
'does not show stop button'
do
expect
(
page
).
not_to
have_link
(
'Stop environment'
)
end
end
end
end
end
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