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
43906336
Commit
43906336
authored
Nov 17, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests and add has_environment?
parent
d6e00f53
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
11 deletions
+45
-11
app/models/ci/build.rb
app/models/ci/build.rb
+7
-3
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+1
-1
app/workers/build_success_worker.rb
app/workers/build_success_worker.rb
+1
-1
spec/models/build_spec.rb
spec/models/build_spec.rb
+35
-3
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-3
No files found.
app/models/ci/build.rb
View file @
43906336
...
@@ -131,12 +131,16 @@ module Ci
...
@@ -131,12 +131,16 @@ module Ci
ExpandVariables
.
expand
(
environment
,
variables
)
if
environment
ExpandVariables
.
expand
(
environment
,
variables
)
if
environment
end
end
def
has_environment?
self
.
environment
.
present?
end
def
starts_environment?
def
starts_environment?
self
.
environment
.
pres
ent?
&&
self
.
environment_action
==
'start'
has_environm
ent?
&&
self
.
environment_action
==
'start'
end
end
def
stops_environment?
def
stops_environment?
self
.
environment
.
pres
ent?
&&
self
.
environment_action
==
'stop'
has_environm
ent?
&&
self
.
environment_action
==
'stop'
end
end
def
environment_action
def
environment_action
...
@@ -148,7 +152,7 @@ module Ci
...
@@ -148,7 +152,7 @@ module Ci
end
end
def
last_deployment
def
last_deployment
deployments
.
order
(
id: :desc
).
last
deployments
.
last
end
end
def
depends_on_builds
def
depends_on_builds
...
...
app/views/projects/builds/show.html.haml
View file @
43906336
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
=
link_to
namespace_project_runners_path
(
@build
.
project
.
namespace
,
@build
.
project
)
do
=
link_to
namespace_project_runners_path
(
@build
.
project
.
namespace
,
@build
.
project
)
do
Runners page
Runners page
-
if
@build
.
environment
.
present?
&&
@build
.
starts_environment?
-
if
@build
.
starts_environment?
.prepend-top-default
.prepend-top-default
.environment-information
.environment-information
-
if
@build
.
outdated_deployment?
-
if
@build
.
outdated_deployment?
...
...
app/workers/build_success_worker.rb
View file @
43906336
...
@@ -4,7 +4,7 @@ class BuildSuccessWorker
...
@@ -4,7 +4,7 @@ class BuildSuccessWorker
def
perform
(
build_id
)
def
perform
(
build_id
)
Ci
::
Build
.
find_by
(
id:
build_id
).
try
do
|
build
|
Ci
::
Build
.
find_by
(
id:
build_id
).
try
do
|
build
|
create_deployment
(
build
)
if
build
.
environment
.
pres
ent?
create_deployment
(
build
)
if
build
.
has_environm
ent?
end
end
end
end
...
...
spec/models/build_spec.rb
View file @
43906336
...
@@ -1053,6 +1053,26 @@ describe Ci::Build, models: true do
...
@@ -1053,6 +1053,26 @@ describe Ci::Build, models: true do
end
end
end
end
describe
'#has_environment?'
do
subject
{
build
.
has_environment?
}
context
'when environment is defined'
do
before
do
build
.
update
(
environment:
'review'
)
end
it
{
is_expected
.
to
be_truthy
}
end
context
'when environment is not defined'
do
before
do
build
.
update
(
environment:
nil
)
end
it
{
is_expected
.
to
be_falsey
}
end
end
describe
'#starts_environment?'
do
describe
'#starts_environment?'
do
subject
{
build
.
starts_environment?
}
subject
{
build
.
starts_environment?
}
...
@@ -1061,9 +1081,19 @@ describe Ci::Build, models: true do
...
@@ -1061,9 +1081,19 @@ describe Ci::Build, models: true do
build
.
update
(
environment:
'review'
)
build
.
update
(
environment:
'review'
)
end
end
context
'no action is defined'
do
it
{
is_expected
.
to
be_truthy
}
it
{
is_expected
.
to
be_truthy
}
end
end
context
'and start action is defined'
do
before
do
build
.
update
(
options:
{
environment:
{
action:
'start'
}
}
)
end
it
{
is_expected
.
to
be_truthy
}
end
end
context
'when environment is not defined'
do
context
'when environment is not defined'
do
before
do
before
do
build
.
update
(
environment:
nil
)
build
.
update
(
environment:
nil
)
...
@@ -1106,11 +1136,13 @@ describe Ci::Build, models: true do
...
@@ -1106,11 +1136,13 @@ describe Ci::Build, models: true do
describe
'#last_deployment'
do
describe
'#last_deployment'
do
subject
{
build
.
last_deployment
}
subject
{
build
.
last_deployment
}
context
'when multiple deployments
is created returns latest one
'
do
context
'when multiple deployments
are created
'
do
let!
(
:deployment1
)
{
create
(
:deployment
,
deployable:
build
)
}
let!
(
:deployment1
)
{
create
(
:deployment
,
deployable:
build
)
}
let!
(
:deployment2
)
{
create
(
:deployment
,
deployable:
build
)
}
let!
(
:deployment2
)
{
create
(
:deployment
,
deployable:
build
)
}
it
{
is_expected
.
to
eq
(
deployment2
)
}
it
'returns the latest one'
do
is_expected
.
to
eq
(
deployment2
)
end
end
end
end
end
...
...
spec/models/ci/build_spec.rb
View file @
43906336
...
@@ -4,13 +4,11 @@ describe Ci::Build, models: true do
...
@@ -4,13 +4,11 @@ describe Ci::Build, models: true do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:test_trace
)
{
'This is a test'
}
let
(
:test_trace
)
{
'This is a test'
}
describe
'ss'
do
it
{
is_expected
.
to
belong_to
(
:runner
)
}
it
{
is_expected
.
to
belong_to
(
:runner
)
}
it
{
is_expected
.
to
belong_to
(
:trigger_request
)
}
it
{
is_expected
.
to
belong_to
(
:trigger_request
)
}
it
{
is_expected
.
to
belong_to
(
:erased_by
)
}
it
{
is_expected
.
to
belong_to
(
:erased_by
)
}
it
{
is_expected
.
to
have_many
(
:deployments
)
}
it
{
is_expected
.
to
have_many
(
:deployments
)
}
end
describe
'#trace'
do
describe
'#trace'
do
it
'obfuscates project runners token'
do
it
'obfuscates project runners token'
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