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
Léo-Paul Géneau
gitlab-ce
Commits
d5eff685
Commit
d5eff685
authored
Aug 17, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve extended CI/CD config specs and fix a bug
parent
a24d4b3c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
11 deletions
+13
-11
lib/gitlab/ci/config/extendable/collection.rb
lib/gitlab/ci/config/extendable/collection.rb
+1
-1
lib/gitlab/ci/config/extendable/entry.rb
lib/gitlab/ci/config/extendable/entry.rb
+5
-4
spec/lib/gitlab/ci/config/extendable/collection_spec.rb
spec/lib/gitlab/ci/config/extendable/collection_spec.rb
+1
-1
spec/lib/gitlab/ci/config/extendable/entry_spec.rb
spec/lib/gitlab/ci/config/extendable/entry_spec.rb
+6
-5
No files found.
lib/gitlab/ci/config/extendable/collection.rb
View file @
d5eff685
...
...
@@ -10,7 +10,7 @@ module Gitlab
CircularDependencyError
=
Class
.
new
(
ExtensionError
)
def
initialize
(
hash
)
@hash
=
hash
.
deep_dup
@hash
=
hash
.
to_h
.
deep_dup
each
{
|
entry
|
entry
.
extend!
if
entry
.
extensible?
}
end
...
...
lib/gitlab/ci/config/extendable/entry.rb
View file @
d5eff685
...
...
@@ -40,16 +40,17 @@ module Gitlab
if
unknown_extension?
raise
Extendable
::
Collection
::
InvalidExtensionError
,
'Unknown extension!'
"Unknown extends key in extended `
#{
key
}
`!"
end
if
invalid_base?
raise
Extendable
::
Collection
::
InvalidExtensionError
,
'Invalid base hash!'
"Invalid base hash in extended `
#{
key
}
`!"
end
if
circular_dependency?
raise
Extendable
::
Collection
::
CircularDependencyError
raise
Extendable
::
Collection
::
CircularDependencyError
,
"Circular dependency detected in extended `
#{
key
}
`!"
end
@context
[
key
]
=
base_hash!
.
deep_merge
(
value
)
...
...
@@ -62,7 +63,7 @@ module Gitlab
end
def
unknown_extension?
!
@context
.
key?
(
key
)
!
@context
.
key?
(
extends_
key
)
end
def
invalid_base?
...
...
spec/lib/gitlab/ci/config/extendable/collection_spec.rb
View file @
d5eff685
...
...
@@ -179,7 +179,7 @@ describe Gitlab::Ci::Config::Extendable::Collection do
end
end
context
'when extensible entry has non-hash inheritace defined'
do
context
'when extensible entry has non-hash inherita
n
ce defined'
do
let
(
:hash
)
do
{
test:
{
...
...
spec/lib/gitlab/ci/config/extendable/entry_spec.rb
View file @
d5eff685
...
...
@@ -115,13 +115,13 @@ describe Gitlab::Ci::Config::Extendable::Entry do
let
(
:hash
)
do
{
first:
'my value'
,
second:
{
extends:
'first'
},
test:
{
extends:
'second'
}
test:
{
extends:
'first'
}
}
end
it
'raises an error'
do
expect
{
subject
.
extend!
}.
to
raise_error
(
StandardError
)
expect
{
subject
.
extend!
}
.
to
raise_error
(
StandardError
,
/Invalid base hash/
)
end
end
...
...
@@ -131,7 +131,8 @@ describe Gitlab::Ci::Config::Extendable::Entry do
end
it
'raises an error'
do
expect
{
subject
.
extend!
}.
to
raise_error
(
StandardError
)
expect
{
subject
.
extend!
}
.
to
raise_error
(
StandardError
,
/Unknown extends key/
)
end
end
...
...
@@ -177,7 +178,7 @@ describe Gitlab::Ci::Config::Extendable::Entry do
end
it
'does not mutate orignal context'
do
original
=
hash
.
dup
original
=
hash
.
d
eep_d
up
subject
.
extend!
...
...
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