Commit 04ecfca3 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Rename CI config null node entry to undefined node

parent 97ec24f0
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment