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
daadeafa
Commit
daadeafa
authored
May 27, 2021
by
Philip Cunningham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add #compact method to Ci::Variables::Collection
- Add new #compact method - Add new specs for #compact
parent
235a261d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
lib/gitlab/ci/variables/collection.rb
lib/gitlab/ci/variables/collection.rb
+4
-0
spec/lib/gitlab/ci/variables/collection_spec.rb
spec/lib/gitlab/ci/variables/collection_spec.rb
+24
-0
No files found.
lib/gitlab/ci/variables/collection.rb
View file @
daadeafa
...
...
@@ -24,6 +24,10 @@ module Gitlab
self
end
def
compact
Collection
.
new
(
select
{
|
variable
|
!
variable
.
value
.
nil?
})
end
def
concat
(
resources
)
return
self
if
resources
.
nil?
...
...
spec/lib/gitlab/ci/variables/collection_spec.rb
View file @
daadeafa
...
...
@@ -44,6 +44,30 @@ RSpec.describe Gitlab::Ci::Variables::Collection do
end
end
describe
'#compact'
do
subject
do
described_class
.
new
.
append
(
key:
'STRING'
,
value:
'string'
)
.
append
(
key:
'NIL'
,
value:
nil
)
.
append
(
key:
nil
,
value:
'string'
)
end
it
'returns a new Collection instance'
,
:aggregate_failures
do
collection
=
subject
.
compact
expect
(
collection
).
to
be_an_instance_of
(
described_class
)
expect
(
collection
).
not_to
eql
(
subject
)
end
it
'rejects pair that has nil value'
,
:aggregate_failures
do
collection
=
subject
.
compact
expect
(
collection
).
not_to
include
(
key:
'NIL'
,
value:
nil
,
public:
true
)
expect
(
collection
).
to
include
(
key:
'STRING'
,
value:
'string'
,
public:
true
)
expect
(
collection
).
to
include
(
key:
nil
,
value:
'string'
,
public:
true
)
end
end
describe
'#concat'
do
it
'appends all elements from an array'
do
collection
=
described_class
.
new
([{
key:
'VAR_1'
,
value:
'1'
}])
...
...
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