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
0a203f40
Commit
0a203f40
authored
Mar 30, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve naming and optimize methods of the build class
parent
1cc96d7a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
app/models/ci/build.rb
app/models/ci/build.rb
+8
-2
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+5
-5
No files found.
app/models/ci/build.rb
View file @
0a203f40
...
@@ -289,7 +289,9 @@ module Ci
...
@@ -289,7 +289,9 @@ module Ci
# Variables that do not depend on the environment name.
# Variables that do not depend on the environment name.
#
#
def
simple_variables
def
simple_variables
scoped_variables
(
environment:
nil
).
to_runner_variables
strong_memoize
(
:simple_variables
)
do
scoped_variables
(
environment:
nil
).
to_runner_variables
end
end
end
##
##
...
@@ -303,7 +305,11 @@ module Ci
...
@@ -303,7 +305,11 @@ module Ci
.
to_runner_variables
.
to_runner_variables
end
end
def
variables_hash
##
# Regular Ruby hash of scoped variables, without duplicates that are
# possible to be present in an array of hashes returned from `variables`.
#
def
scoped_variables_hash
scoped_variables
.
to_hash
scoped_variables
.
to_hash
end
end
...
...
spec/models/ci/build_spec.rb
View file @
0a203f40
...
@@ -2070,7 +2070,7 @@ describe Ci::Build do
...
@@ -2070,7 +2070,7 @@ describe Ci::Build do
end
end
end
end
describe
'#variables_hash'
do
describe
'#
scoped_
variables_hash'
do
context
'when overriding secret variables'
do
context
'when overriding secret variables'
do
before
do
before
do
project
.
variables
.
create!
(
key:
'MY_VAR'
,
value:
'my value 1'
)
project
.
variables
.
create!
(
key:
'MY_VAR'
,
value:
'my value 1'
)
...
@@ -2078,8 +2078,8 @@ describe Ci::Build do
...
@@ -2078,8 +2078,8 @@ describe Ci::Build do
end
end
it
'returns a regular hash created using valid ordering'
do
it
'returns a regular hash created using valid ordering'
do
expect
(
build
.
variables_hash
).
to
include
(
'MY_VAR'
:
'my value 2'
)
expect
(
build
.
scoped_
variables_hash
).
to
include
(
'MY_VAR'
:
'my value 2'
)
expect
(
build
.
variables_hash
).
not_to
include
(
'MY_VAR'
:
'my value 1'
)
expect
(
build
.
scoped_
variables_hash
).
not_to
include
(
'MY_VAR'
:
'my value 1'
)
end
end
end
end
...
@@ -2090,8 +2090,8 @@ describe Ci::Build do
...
@@ -2090,8 +2090,8 @@ describe Ci::Build do
end
end
it
'returns a hash including variable with higher precedence'
do
it
'returns a hash including variable with higher precedence'
do
expect
(
build
.
variables_hash
).
to
include
(
'MY_VAR'
:
'pipeline value'
)
expect
(
build
.
scoped_
variables_hash
).
to
include
(
'MY_VAR'
:
'pipeline value'
)
expect
(
build
.
variables_hash
).
not_to
include
(
'MY_VAR'
:
'myvar'
)
expect
(
build
.
scoped_
variables_hash
).
not_to
include
(
'MY_VAR'
:
'myvar'
)
end
end
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