BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b74b7309
Commit
b74b7309
authored
May 25, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for CI_ENVIRONMENT_URL
parent
3e190d80
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
10 deletions
+60
-10
build.rb
app/models/ci/build.rb
+7
-4
build_spec.rb
spec/models/ci/build_spec.rb
+53
-6
No files found.
app/models/ci/build.rb
View file @
b74b7309
...
...
@@ -499,10 +499,13 @@ module Ci
end
def
persisted_environment_variables
persisted_environment
.
predefined_variables
<<
{
key:
'CI_ENVIRONMENT_URL'
,
value:
expanded_environment_url
,
public:
true
}
variables
=
persisted_environment
.
predefined_variables
variables
<<
{
key:
'CI_ENVIRONMENT_URL'
,
value:
expanded_environment_url
,
public:
true
}
if
environment_url
variables
end
def
legacy_variables
...
...
spec/models/ci/build_spec.rb
View file @
b74b7309
...
...
@@ -20,6 +20,7 @@ describe Ci::Build, :models do
it
{
is_expected
.
to
validate_presence_of
(
:ref
)
}
it
{
is_expected
.
to
respond_to
(
:has_trace?
)
}
it
{
is_expected
.
to
respond_to
(
:trace
)
}
it
{
is_expected
.
to
validate_length_of
(
:external_url
).
is_at_most
(
255
)
}
describe
'#actionize'
do
context
'when build is a created'
do
...
...
@@ -427,6 +428,30 @@ describe Ci::Build, :models do
end
end
describe
'#expanded_environment_url'
do
subject
{
build
.
expanded_environment_url
}
context
'when environment uses $CI_COMMIT_REF_NAME'
do
let
(
:build
)
do
create
(
:ci_build
,
ref:
'master'
,
environment_url:
'http://review/$CI_COMMIT_REF_NAME'
)
end
it
{
is_expected
.
to
eq
(
'http://review/master'
)
}
end
context
'when environment uses yaml_variables containing symbol keys'
do
let
(
:build
)
do
create
(
:ci_build
,
yaml_variables:
[{
key: :APP_HOST
,
value:
'host'
}],
environment_url:
'http://review/$APP_HOST'
)
end
it
{
is_expected
.
to
eq
(
'http://review/host'
)
}
end
end
describe
'#starts_environment?'
do
subject
{
build
.
starts_environment?
}
...
...
@@ -1176,11 +1201,6 @@ describe Ci::Build, :models do
end
context
'when build has an environment'
do
before
do
build
.
update
(
environment:
'production'
)
create
(
:environment
,
project:
build
.
project
,
name:
'production'
,
slug:
'prod-slug'
)
end
let
(
:environment_variables
)
do
[
{
key:
'CI_ENVIRONMENT_NAME'
,
value:
'production'
,
public:
true
},
...
...
@@ -1188,7 +1208,34 @@ describe Ci::Build, :models do
]
end
it
{
environment_variables
.
each
{
|
v
|
is_expected
.
to
include
(
v
)
}
}
before
do
build
.
update
(
environment:
'production'
)
create
(
:environment
,
project:
build
.
project
,
name:
'production'
,
slug:
'prod-slug'
)
end
context
'when no URL was set'
do
it
{
environment_variables
.
each
{
|
v
|
is_expected
.
to
include
(
v
)
}
}
it
'does not have CI_ENVIRONMENT_URL'
do
keys
=
subject
.
map
{
|
var
|
var
[
:key
]
}
expect
(
keys
).
to
include
(
'CI_ENVIRONMENT_NAME'
,
'CI_ENVIRONMENT_SLUG'
)
expect
(
keys
).
not_to
include
(
'CI_ENVIRONMENT_URL'
)
end
end
context
'when an URL was set'
do
before
do
build
.
update
(
environment_url:
'http://host/$CI_JOB_NAME'
)
environment_variables
<<
{
key:
'CI_ENVIRONMENT_URL'
,
value:
'http://host/test'
,
public:
true
}
end
it
{
environment_variables
.
each
{
|
v
|
is_expected
.
to
include
(
v
)
}
}
end
end
context
'when build started manually'
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