summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gitlab/ci/config/node/configurable.rb2
-rw-r--r--lib/gitlab/ci/config/node/factory.rb6
-rw-r--r--lib/gitlab/ci/config/node/undefined.rb (renamed from lib/gitlab/ci/config/node/null.rb)17
-rw-r--r--spec/lib/gitlab/ci/config/node/factory_spec.rb6
-rw-r--r--spec/lib/gitlab/ci/config/node/undefined_spec.rb (renamed from spec/lib/gitlab/ci/config/node/null_spec.rb)8
5 files changed, 16 insertions, 23 deletions
diff --git a/lib/gitlab/ci/config/node/configurable.rb b/lib/gitlab/ci/config/node/configurable.rb
index e691ab0c5cf..f26924fab26 100644
--- a/lib/gitlab/ci/config/node/configurable.rb
+++ b/lib/gitlab/ci/config/node/configurable.rb
@@ -27,7 +27,7 @@ module Gitlab
def create_node(key, factory)
factory.with(value: @config[key], key: key)
- factory.nullify! unless @config.has_key?(key)
+ factory.undefine! unless @config.has_key?(key)
factory.create!
end
diff --git a/lib/gitlab/ci/config/node/factory.rb b/lib/gitlab/ci/config/node/factory.rb
index 025ae40ef94..dbf027b6d8e 100644
--- a/lib/gitlab/ci/config/node/factory.rb
+++ b/lib/gitlab/ci/config/node/factory.rb
@@ -5,8 +5,6 @@ module Gitlab
##
# Factory class responsible for fabricating node entry objects.
#
- # It uses Fluent Interface pattern to set all necessary attributes.
- #
class Factory
class InvalidFactory < StandardError; end
@@ -20,8 +18,8 @@ module Gitlab
self
end
- def nullify!
- @entry_class = Node::Null
+ def undefine!
+ @entry_class = Node::Undefined
self
end
diff --git a/lib/gitlab/ci/config/node/null.rb b/lib/gitlab/ci/config/node/undefined.rb
index 4f590f6bec8..a812d803f3e 100644
--- a/lib/gitlab/ci/config/node/null.rb
+++ b/lib/gitlab/ci/config/node/undefined.rb
@@ -3,20 +3,15 @@ module Gitlab
class Config
module Node
##
- # This class represents a configuration entry that is not being used
+ # This class represents a configuration entry that is not defined
# in configuration file.
#
- # This implements Null Object pattern.
+ # This implements a Null Object pattern.
#
- class Null < Entry
- def value
- nil
- end
-
- def validate!
- nil
- end
-
+ # It can be initialized using a default value of entry that is not
+ # present in configuration.
+ #
+ class Undefined < Entry
def method_missing(*)
nil
end
diff --git a/spec/lib/gitlab/ci/config/node/factory_spec.rb b/spec/lib/gitlab/ci/config/node/factory_spec.rb
index 10462db7699..8e13e243d4d 100644
--- a/spec/lib/gitlab/ci/config/node/factory_spec.rb
+++ b/spec/lib/gitlab/ci/config/node/factory_spec.rb
@@ -45,14 +45,14 @@ describe Gitlab::Ci::Config::Node::Factory do
end
end
- context 'when creating a null entry' do
+ context 'when creating undefined entry' do
it 'creates a null entry' do
entry = factory
.with(value: nil)
- .nullify!
+ .undefine!
.create!
- expect(entry).to be_an_instance_of Gitlab::Ci::Config::Node::Null
+ expect(entry).to be_an_instance_of Gitlab::Ci::Config::Node::Undefined
end
end
end
diff --git a/spec/lib/gitlab/ci/config/node/null_spec.rb b/spec/lib/gitlab/ci/config/node/undefined_spec.rb
index 36101c62462..2d01a8a6ec8 100644
--- a/spec/lib/gitlab/ci/config/node/null_spec.rb
+++ b/spec/lib/gitlab/ci/config/node/undefined_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
-describe Gitlab::Ci::Config::Node::Null do
- let(:entry) { described_class.new(nil) }
+describe Gitlab::Ci::Config::Node::Undefined do
+ let(:entry) { described_class.new('some value') }
describe '#leaf?' do
it 'is leaf node' do
@@ -16,8 +16,8 @@ describe Gitlab::Ci::Config::Node::Null do
end
describe '#value' do
- it 'returns nil' do
- expect(entry.value).to be nil
+ it 'returns configured value' do
+ expect(entry.value).to eq 'some value'
end
end
end