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
Jérome Perrin
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
Hide 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
ExpandVariables
.
expand
(
environment
,
variables
)
if
environment
end
def
has_environment?
self
.
environment
.
present?
end
def
starts_environment?
self
.
environment
.
pres
ent?
&&
self
.
environment_action
==
'start'
has_environm
ent?
&&
self
.
environment_action
==
'start'
end
def
stops_environment?
self
.
environment
.
pres
ent?
&&
self
.
environment_action
==
'stop'
has_environm
ent?
&&
self
.
environment_action
==
'stop'
end
def
environment_action
...
...
@@ -148,7 +152,7 @@ module Ci
end
def
last_deployment
deployments
.
order
(
id: :desc
).
last
deployments
.
last
end
def
depends_on_builds
...
...
app/views/projects/builds/show.html.haml
View file @
43906336
...
...
@@ -26,7 +26,7 @@
=
link_to
namespace_project_runners_path
(
@build
.
project
.
namespace
,
@build
.
project
)
do
Runners page
-
if
@build
.
environment
.
present?
&&
@build
.
starts_environment?
-
if
@build
.
starts_environment?
.prepend-top-default
.environment-information
-
if
@build
.
outdated_deployment?
...
...
app/workers/build_success_worker.rb
View file @
43906336
...
...
@@ -4,7 +4,7 @@ class BuildSuccessWorker
def
perform
(
build_id
)
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
...
...
spec/models/build_spec.rb
View file @
43906336
...
...
@@ -1053,6 +1053,26 @@ describe Ci::Build, models: true do
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
subject
{
build
.
starts_environment?
}
...
...
@@ -1061,7 +1081,17 @@ describe Ci::Build, models: true do
build
.
update
(
environment:
'review'
)
end
it
{
is_expected
.
to
be_truthy
}
context
'no action is defined'
do
it
{
is_expected
.
to
be_truthy
}
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
...
...
@@ -1106,11 +1136,13 @@ describe Ci::Build, models: true do
describe
'#last_deployment'
do
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!
(
: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
...
...
spec/models/ci/build_spec.rb
View file @
43906336
...
...
@@ -4,14 +4,12 @@ describe Ci::Build, models: true do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:test_trace
)
{
'This is a test'
}
describe
'ss'
do
it
{
is_expected
.
to
belong_to
(
:runner
)
}
it
{
is_expected
.
to
belong_to
(
:trigger_request
)
}
it
{
is_expected
.
to
belong_to
(
:erased_by
)
}
it
{
is_expected
.
to
have_many
(
:deployments
)
}
end
describe
'#trace'
do
it
'obfuscates project runners token'
do
allow
(
build
).
to
receive
(
:raw_trace
).
and_return
(
"Test:
#{
build
.
project
.
runners_token
}
"
)
...
...
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