diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-08-17 13:53:04 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-09-04 15:17:01 +0300 |
commit | d5eff68576361f43e5979bb713ecb823323c24bb (patch) | |
tree | 492fb7f829b98d067ff912f0d69626f44c6c5ea4 /lib | |
parent | a24d4b3c674452ecb63f5a250b619362cc24630c (diff) |
Improve extended CI/CD config specs and fix a bug
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/config/extendable/collection.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/config/extendable/entry.rb | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/gitlab/ci/config/extendable/collection.rb b/lib/gitlab/ci/config/extendable/collection.rb index b57b3aa5d47..123219c90f2 100644 --- a/lib/gitlab/ci/config/extendable/collection.rb +++ b/lib/gitlab/ci/config/extendable/collection.rb @@ -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 diff --git a/lib/gitlab/ci/config/extendable/entry.rb b/lib/gitlab/ci/config/extendable/entry.rb index 5b26faaa806..f14d2c1817c 100644 --- a/lib/gitlab/ci/config/extendable/entry.rb +++ b/lib/gitlab/ci/config/extendable/entry.rb @@ -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? |