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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
44cc1b9f
Commit
44cc1b9f
authored
Jan 28, 2021
by
Pedro Pombeiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scope variable_inside_variable to project
parent
981ad651
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
lib/gitlab/ci/variables/collection/sorted.rb
lib/gitlab/ci/variables/collection/sorted.rb
+4
-3
spec/lib/gitlab/ci/variables/collection/sorted_spec.rb
spec/lib/gitlab/ci/variables/collection/sorted_spec.rb
+14
-6
spec/presenters/ci/build_runner_presenter_spec.rb
spec/presenters/ci/build_runner_presenter_spec.rb
+2
-2
No files found.
lib/gitlab/ci/variables/collection/sorted.rb
View file @
44cc1b9f
...
@@ -8,8 +8,9 @@ module Gitlab
...
@@ -8,8 +8,9 @@ module Gitlab
include
TSort
include
TSort
include
Gitlab
::
Utils
::
StrongMemoize
include
Gitlab
::
Utils
::
StrongMemoize
def
initialize
(
variables
)
def
initialize
(
variables
,
project
)
@variables
=
variables
@variables
=
variables
@project
=
project
end
end
def
valid?
def
valid?
...
@@ -19,7 +20,7 @@ module Gitlab
...
@@ -19,7 +20,7 @@ module Gitlab
# errors sorts an array of variables, ignoring unknown variable references,
# errors sorts an array of variables, ignoring unknown variable references,
# and returning an error string if a circular variable reference is found
# and returning an error string if a circular variable reference is found
def
errors
def
errors
return
if
Feature
.
disabled?
(
:variable_inside_variable
)
return
if
Feature
.
disabled?
(
:variable_inside_variable
,
@project
)
strong_memoize
(
:errors
)
do
strong_memoize
(
:errors
)
do
# Check for cyclic dependencies and build error message in that case
# Check for cyclic dependencies and build error message in that case
...
@@ -34,7 +35,7 @@ module Gitlab
...
@@ -34,7 +35,7 @@ module Gitlab
# sort sorts an array of variables, ignoring unknown variable references.
# sort sorts an array of variables, ignoring unknown variable references.
# If a circular variable reference is found, the original array is returned
# If a circular variable reference is found, the original array is returned
def
sort
def
sort
return
@variables
if
Feature
.
disabled?
(
:variable_inside_variable
)
return
@variables
if
Feature
.
disabled?
(
:variable_inside_variable
,
@project
)
return
@variables
if
errors
return
@variables
if
errors
tsort
tsort
...
...
spec/lib/gitlab/ci/variables/collection/sorted_spec.rb
View file @
44cc1b9f
...
@@ -5,8 +5,11 @@ require 'spec_helper'
...
@@ -5,8 +5,11 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Ci
::
Variables
::
Collection
::
Sorted
do
RSpec
.
describe
Gitlab
::
Ci
::
Variables
::
Collection
::
Sorted
do
describe
'#errors'
do
describe
'#errors'
do
context
'when FF :variable_inside_variable is disabled'
do
context
'when FF :variable_inside_variable is disabled'
do
let_it_be
(
:project_with_flag_disabled
)
{
create
(
:project
)
}
let_it_be
(
:project_with_flag_enabled
)
{
create
(
:project
)
}
before
do
before
do
stub_feature_flags
(
variable_inside_variable:
false
)
stub_feature_flags
(
variable_inside_variable:
[
project_with_flag_enabled
]
)
end
end
context
'table tests'
do
context
'table tests'
do
...
@@ -53,7 +56,7 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
...
@@ -53,7 +56,7 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
end
end
with_them
do
with_them
do
subject
{
Gitlab
::
Ci
::
Variables
::
Collection
::
Sorted
.
new
(
variables
)
}
subject
{
Gitlab
::
Ci
::
Variables
::
Collection
::
Sorted
.
new
(
variables
,
project_with_flag_disabled
)
}
it
'does not report error'
do
it
'does not report error'
do
expect
(
subject
.
errors
).
to
eq
(
nil
)
expect
(
subject
.
errors
).
to
eq
(
nil
)
...
@@ -67,8 +70,11 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
...
@@ -67,8 +70,11 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
end
end
context
'when FF :variable_inside_variable is enabled'
do
context
'when FF :variable_inside_variable is enabled'
do
let_it_be
(
:project_with_flag_disabled
)
{
create
(
:project
)
}
let_it_be
(
:project_with_flag_enabled
)
{
create
(
:project
)
}
before
do
before
do
stub_feature_flags
(
variable_inside_variable:
true
)
stub_feature_flags
(
variable_inside_variable:
[
project_with_flag_enabled
]
)
end
end
context
'table tests'
do
context
'table tests'
do
...
@@ -100,7 +106,7 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
...
@@ -100,7 +106,7 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
end
end
with_them
do
with_them
do
subject
{
Gitlab
::
Ci
::
Variables
::
Collection
::
Sorted
.
new
(
variables
)
}
subject
{
Gitlab
::
Ci
::
Variables
::
Collection
::
Sorted
.
new
(
variables
,
project_with_flag_enabled
)
}
it
'errors matches expected validation result'
do
it
'errors matches expected validation result'
do
expect
(
subject
.
errors
).
to
eq
(
validation_result
)
expect
(
subject
.
errors
).
to
eq
(
validation_result
)
...
@@ -164,7 +170,8 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
...
@@ -164,7 +170,8 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
end
end
with_them
do
with_them
do
subject
{
Gitlab
::
Ci
::
Variables
::
Collection
::
Sorted
.
new
(
variables
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
subject
{
Gitlab
::
Ci
::
Variables
::
Collection
::
Sorted
.
new
(
variables
,
project
)
}
it
'does not expand variables'
do
it
'does not expand variables'
do
expect
(
subject
.
sort
).
to
eq
(
variables
)
expect
(
subject
.
sort
).
to
eq
(
variables
)
...
@@ -239,7 +246,8 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
...
@@ -239,7 +246,8 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
end
end
with_them
do
with_them
do
subject
{
Gitlab
::
Ci
::
Variables
::
Collection
::
Sorted
.
new
(
variables
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
subject
{
Gitlab
::
Ci
::
Variables
::
Collection
::
Sorted
.
new
(
variables
,
project
)
}
it
'sort returns correctly sorted variables'
do
it
'sort returns correctly sorted variables'
do
expect
(
subject
.
sort
.
map
{
|
var
|
var
[
:key
]
}).
to
eq
(
result
)
expect
(
subject
.
sort
.
map
{
|
var
|
var
[
:key
]
}).
to
eq
(
result
)
...
...
spec/presenters/ci/build_runner_presenter_spec.rb
View file @
44cc1b9f
...
@@ -17,7 +17,7 @@ RSpec.describe Ci::BuildRunnerPresenter do
...
@@ -17,7 +17,7 @@ RSpec.describe Ci::BuildRunnerPresenter do
describe
'#artifacts'
do
describe
'#artifacts'
do
context
"when option contains archive-type artifacts"
do
context
"when option contains archive-type artifacts"
do
let
(
:build
)
{
create
(
:ci_build
,
options:
{
artifacts:
archive
}
)
}
let
(
:build
)
{
create
(
:ci_build
,
options:
{
artifacts:
archive
})
}
it
'presents correct hash'
do
it
'presents correct hash'
do
expect
(
presenter
.
artifacts
.
first
).
to
include
(
archive_expectation
)
expect
(
presenter
.
artifacts
.
first
).
to
include
(
archive_expectation
)
...
...
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