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
Boxiang Sun
gitlab-ce
Commits
20047e72
Commit
20047e72
authored
May 31, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix environment specs related to protected actions
parent
f8eb8fea
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
21 deletions
+39
-21
app/views/projects/deployments/_actions.haml
app/views/projects/deployments/_actions.haml
+1
-0
app/views/projects/environments/show.html.haml
app/views/projects/environments/show.html.haml
+1
-1
spec/features/projects/environments/environment_spec.rb
spec/features/projects/environments/environment_spec.rb
+37
-20
No files found.
app/views/projects/deployments/_actions.haml
View file @
20047e72
...
...
@@ -8,6 +8,7 @@
=
icon
(
'caret-down'
)
%ul
.dropdown-menu.dropdown-menu-align-right
-
actions
.
each
do
|
action
|
-
next
unless
can?
(
current_user
,
:update_build
,
action
)
%li
=
link_to
[
:play
,
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
action
],
method: :post
,
rel:
'nofollow'
do
=
custom_icon
(
'icon_play'
)
...
...
app/views/projects/environments/show.html.haml
View file @
20047e72
...
...
@@ -13,7 +13,7 @@
=
render
'projects/environments/metrics_button'
,
environment:
@environment
-
if
can?
(
current_user
,
:update_environment
,
@environment
)
=
link_to
'Edit'
,
edit_namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@environment
),
class:
'btn'
-
if
can?
(
current_user
,
:
create_deployment
,
@environment
)
&&
@environment
.
can_stop?
-
if
can?
(
current_user
,
:
stop_environment
,
@environment
)
=
link_to
'Stop'
,
stop_namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@environment
),
data:
{
confirm:
'Are you sure you want to stop this environment?'
},
class:
'btn btn-danger'
,
method: :post
.environments-container
...
...
spec/features/projects/environments/environment_spec.rb
View file @
20047e72
...
...
@@ -12,6 +12,7 @@ feature 'Environment', :feature do
feature
'environment details page'
do
given!
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
given!
(
:permissions
)
{
}
given!
(
:deployment
)
{
}
given!
(
:action
)
{
}
...
...
@@ -62,13 +63,17 @@ feature 'Environment', :feature do
name:
'deploy to production'
)
end
given
(
:role
)
{
:master
}
context
'when user has ability to trigger deployment'
do
given
(
:permissions
)
do
create
(
:protected_branch
,
:developers_can_merge
,
name:
action
.
ref
,
project:
project
)
end
scenario
'does show a play button'
do
it
'does show a play button'
do
expect
(
page
).
to
have_link
(
action
.
name
.
humanize
)
end
scenario
'does allow to play manual action'
do
it
'does allow to play manual action'
do
expect
(
action
).
to
be_manual
expect
{
click_link
(
action
.
name
.
humanize
)
}
...
...
@@ -77,6 +82,13 @@ feature 'Environment', :feature do
expect
(
page
).
to
have_content
(
action
.
name
)
expect
(
action
.
reload
).
to
be_pending
end
end
context
'when user has no ability to trigger a deployment'
do
it
'does not show a play button'
do
expect
(
page
).
not_to
have_link
(
action
.
name
.
humanize
)
end
end
context
'with external_url'
do
given
(
:environment
)
{
create
(
:environment
,
project:
project
,
external_url:
'https://git.gitlab.com'
)
}
...
...
@@ -134,13 +146,24 @@ feature 'Environment', :feature do
on_stop:
'close_app'
)
end
given
(
:role
)
{
:master
}
context
'when user has ability to stop environment'
do
given
(
:permissions
)
do
create
(
:protected_branch
,
:developers_can_merge
,
name:
action
.
ref
,
project:
project
)
end
scenario
'does allow
to stop environment'
do
it
'allows
to stop environment'
do
click_link
(
'Stop'
)
expect
(
page
).
to
have_content
(
'close_app'
)
end
end
context
'when user has no ability to stop environment'
do
it
'does not allow to stop environment'
do
expect
(
page
).
to
have_no_link
(
'Stop'
)
end
end
context
'for reporter'
do
let
(
:role
)
{
:reporter
}
...
...
@@ -150,12 +173,6 @@ feature 'Environment', :feature do
end
end
end
context
'without stop action'
do
scenario
'does allow to stop environment'
do
click_link
(
'Stop'
)
end
end
end
context
'when environment is stopped'
do
...
...
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