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
149c2917
Commit
149c2917
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
c0b67036
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 @
149c2917
...
@@ -10,7 +10,7 @@ module Gitlab
...
@@ -10,7 +10,7 @@ module Gitlab
CircularDependencyError
=
Class
.
new
(
ExtensionError
)
CircularDependencyError
=
Class
.
new
(
ExtensionError
)
def
initialize
(
hash
)
def
initialize
(
hash
)
@hash
=
hash
.
deep_dup
@hash
=
hash
.
to_h
.
deep_dup
each
{
|
entry
|
entry
.
extend!
if
entry
.
extensible?
}
each
{
|
entry
|
entry
.
extend!
if
entry
.
extensible?
}
end
end
...
...
lib/gitlab/ci/config/extendable/entry.rb
View file @
149c2917
...
@@ -40,16 +40,17 @@ module Gitlab
...
@@ -40,16 +40,17 @@ module Gitlab
if
unknown_extension?
if
unknown_extension?
raise
Extendable
::
Collection
::
InvalidExtensionError
,
raise
Extendable
::
Collection
::
InvalidExtensionError
,
'Unknown extension!'
"Unknown extends key in extended `
#{
key
}
`!"
end
end
if
invalid_base?
if
invalid_base?
raise
Extendable
::
Collection
::
InvalidExtensionError
,
raise
Extendable
::
Collection
::
InvalidExtensionError
,
'Invalid base hash!'
"Invalid base hash in extended `
#{
key
}
`!"
end
end
if
circular_dependency?
if
circular_dependency?
raise
Extendable
::
Collection
::
CircularDependencyError
raise
Extendable
::
Collection
::
CircularDependencyError
,
"Circular dependency detected in extended `
#{
key
}
`!"
end
end
@context
[
key
]
=
base_hash!
.
deep_merge
(
value
)
@context
[
key
]
=
base_hash!
.
deep_merge
(
value
)
...
@@ -62,7 +63,7 @@ module Gitlab
...
@@ -62,7 +63,7 @@ module Gitlab
end
end
def
unknown_extension?
def
unknown_extension?
!
@context
.
key?
(
key
)
!
@context
.
key?
(
extends_
key
)
end
end
def
invalid_base?
def
invalid_base?
...
...
spec/lib/gitlab/ci/config/extendable/collection_spec.rb
View file @
149c2917
...
@@ -179,7 +179,7 @@ describe Gitlab::Ci::Config::Extendable::Collection do
...
@@ -179,7 +179,7 @@ describe Gitlab::Ci::Config::Extendable::Collection do
end
end
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
let
(
:hash
)
do
{
{
test:
{
test:
{
...
...
spec/lib/gitlab/ci/config/extendable/entry_spec.rb
View file @
149c2917
...
@@ -115,13 +115,13 @@ describe Gitlab::Ci::Config::Extendable::Entry do
...
@@ -115,13 +115,13 @@ describe Gitlab::Ci::Config::Extendable::Entry do
let
(
:hash
)
do
let
(
:hash
)
do
{
{
first:
'my value'
,
first:
'my value'
,
second:
{
extends:
'first'
},
test:
{
extends:
'first'
}
test:
{
extends:
'second'
}
}
}
end
end
it
'raises an error'
do
it
'raises an error'
do
expect
{
subject
.
extend!
}.
to
raise_error
(
StandardError
)
expect
{
subject
.
extend!
}
.
to
raise_error
(
StandardError
,
/Invalid base hash/
)
end
end
end
end
...
@@ -131,7 +131,8 @@ describe Gitlab::Ci::Config::Extendable::Entry do
...
@@ -131,7 +131,8 @@ describe Gitlab::Ci::Config::Extendable::Entry do
end
end
it
'raises an error'
do
it
'raises an error'
do
expect
{
subject
.
extend!
}.
to
raise_error
(
StandardError
)
expect
{
subject
.
extend!
}
.
to
raise_error
(
StandardError
,
/Unknown extends key/
)
end
end
end
end
...
@@ -177,7 +178,7 @@ describe Gitlab::Ci::Config::Extendable::Entry do
...
@@ -177,7 +178,7 @@ describe Gitlab::Ci::Config::Extendable::Entry do
end
end
it
'does not mutate orignal context'
do
it
'does not mutate orignal context'
do
original
=
hash
.
dup
original
=
hash
.
d
eep_d
up
subject
.
extend!
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