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
d4319e17
Commit
d4319e17
authored
Mar 13, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more unit tests for variables collection class
parent
e16fba67
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
1 deletion
+33
-1
lib/gitlab/ci/variables/collection.rb
lib/gitlab/ci/variables/collection.rb
+0
-1
spec/lib/gitlab/ci/variables/collection/item_spec.rb
spec/lib/gitlab/ci/variables/collection/item_spec.rb
+8
-0
spec/lib/gitlab/ci/variables/collection_spec.rb
spec/lib/gitlab/ci/variables/collection_spec.rb
+25
-0
No files found.
lib/gitlab/ci/variables/collection.rb
View file @
d4319e17
...
@@ -14,7 +14,6 @@ module Gitlab
...
@@ -14,7 +14,6 @@ module Gitlab
@variables
.
append
(
Collection
::
Item
.
fabricate
(
resource
))
@variables
.
append
(
Collection
::
Item
.
fabricate
(
resource
))
end
end
# TODO, specs
def
concat
(
resources
)
def
concat
(
resources
)
resources
.
each
{
|
variable
|
self
.
append
(
variable
)
}
resources
.
each
{
|
variable
|
self
.
append
(
variable
)
}
end
end
...
...
spec/lib/gitlab/ci/variables/collection/item_spec.rb
View file @
d4319e17
...
@@ -39,6 +39,14 @@ describe Gitlab::Ci::Variables::Collection::Item do
...
@@ -39,6 +39,14 @@ describe Gitlab::Ci::Variables::Collection::Item do
end
end
end
end
describe
'#[]'
do
it
'behaves like a hash accessor'
do
item
=
described_class
.
new
(
**
variable
)
expect
(
item
[
:key
]).
to
eq
'VAR'
end
end
describe
'#to_hash'
do
describe
'#to_hash'
do
it
'returns a hash representation of a collection item'
do
it
'returns a hash representation of a collection item'
do
expect
(
described_class
.
new
(
**
variable
).
to_hash
).
to
eq
variable
expect
(
described_class
.
new
(
**
variable
).
to_hash
).
to
eq
variable
...
...
spec/lib/gitlab/ci/variables/collection_spec.rb
View file @
d4319e17
...
@@ -37,6 +37,31 @@ describe Gitlab::Ci::Variables::Collection do
...
@@ -37,6 +37,31 @@ describe Gitlab::Ci::Variables::Collection do
end
end
end
end
describe
'#concat'
do
it
'appends all elements from an array'
do
collection
=
described_class
.
new
([{
key:
'VAR_1'
,
value:
'1'
}])
variables
=
[{
key:
'VAR_2'
,
value:
'2'
},
{
key:
'VAR_3'
,
value:
'3'
}]
collection
.
concat
(
variables
)
expect
(
collection
).
to
include
(
key:
'VAR_1'
,
value:
'1'
,
public:
true
)
expect
(
collection
).
to
include
(
key:
'VAR_2'
,
value:
'2'
,
public:
true
)
expect
(
collection
).
to
include
(
key:
'VAR_3'
,
value:
'3'
,
public:
true
)
end
it
'appends all elements from other collection'
do
collection
=
described_class
.
new
([{
key:
'VAR_1'
,
value:
'1'
}])
additional
=
described_class
.
new
([{
key:
'VAR_2'
,
value:
'2'
},
{
key:
'VAR_3'
,
value:
'3'
}])
collection
.
concat
(
additional
)
expect
(
collection
).
to
include
(
key:
'VAR_1'
,
value:
'1'
,
public:
true
)
expect
(
collection
).
to
include
(
key:
'VAR_2'
,
value:
'2'
,
public:
true
)
expect
(
collection
).
to
include
(
key:
'VAR_3'
,
value:
'3'
,
public:
true
)
end
end
describe
'#+'
do
describe
'#+'
do
it
'makes it possible to combine with an array'
do
it
'makes it possible to combine with an array'
do
collection
=
described_class
.
new
([{
key:
'TEST'
,
value:
1
}])
collection
=
described_class
.
new
([{
key:
'TEST'
,
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