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
iv
gitlab-ce
Commits
30877eff
Commit
30877eff
authored
Jun 14, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test environment controller specs
parent
6209b60c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
168 additions
and
1 deletion
+168
-1
app/models/deployment.rb
app/models/deployment.rb
+4
-0
app/views/projects/deployments/_deployment.html.haml
app/views/projects/deployments/_deployment.html.haml
+5
-1
spec/features/environments_spec.rb
spec/features/environments_spec.rb
+159
-0
No files found.
app/models/deployment.rb
View file @
30877eff
...
...
@@ -24,4 +24,8 @@ class Deployment < ActiveRecord::Base
def
short_sha
Commit
::
truncate_sha
(
sha
)
end
def
last?
self
==
environment
.
last_deployment
end
end
app/views/projects/deployments/_deployment.html.haml
View file @
30877eff
...
...
@@ -27,4 +27,8 @@
%td
-
if
can?
(
current_user
,
:update_deployment
,
@project
)
&&
deployment
.
deployable
.pull-right
=
link_to
'Retry'
,
retry_namespace_project_build_path
(
@project
.
namespace
,
@project
,
deployment
.
deployable
),
method: :post
,
class:
'btn btn-build'
=
link_to
retry_namespace_project_build_path
(
@project
.
namespace
,
@project
,
deployment
.
deployable
),
method: :post
,
class:
'btn btn-build'
do
-
if
deployment
.
last?
Retry
-
else
Rollback
spec/features/environments_spec.rb
0 → 100644
View file @
30877eff
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
(
'Environment 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
(
'Environment 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 developer'
do
before
{
click_link
'Destroy'
}
it
'does not have environment'
do
expect
(
page
).
not_to
have_link
(
environment
.
name
)
end
end
context
'when logged as reporter'
do
let
(
:role
)
{
:reporter
}
it
'does not have a Destroy link'
do
expect
(
page
).
not_to
have_link
(
'Destroy'
)
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