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 ...@@ -27,7 +27,7 @@ module Gitlab
def create_node(key, factory) def create_node(key, factory)
factory.with(value: @config[key], key: key) factory.with(value: @config[key], key: key)
factory.nullify! unless @config.has_key?(key) factory.undefine! unless @config.has_key?(key)
factory.create! factory.create!
end end
......
...@@ -5,8 +5,6 @@ module Gitlab ...@@ -5,8 +5,6 @@ module Gitlab
## ##
# Factory class responsible for fabricating node entry objects. # Factory class responsible for fabricating node entry objects.
# #
# It uses Fluent Interface pattern to set all necessary attributes.
#
class Factory class Factory
class InvalidFactory < StandardError; end class InvalidFactory < StandardError; end
...@@ -20,8 +18,8 @@ module Gitlab ...@@ -20,8 +18,8 @@ module Gitlab
self self
end end
def nullify! def undefine!
@entry_class = Node::Null @entry_class = Node::Undefined
self self
end end
......
...@@ -3,20 +3,15 @@ module Gitlab ...@@ -3,20 +3,15 @@ module Gitlab
class Config class Config
module Node 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. # in configuration file.
# #
# This implements Null Object pattern. # This implements a Null Object pattern.
# #
class Null < Entry # It can be initialized using a default value of entry that is not
def value # present in configuration.
nil #
end class Undefined < Entry
def validate!
nil
end
def method_missing(*) def method_missing(*)
nil nil
end end
......
...@@ -45,14 +45,14 @@ describe Gitlab::Ci::Config::Node::Factory do ...@@ -45,14 +45,14 @@ describe Gitlab::Ci::Config::Node::Factory do
end end
end end
context 'when creating a null entry' do context 'when creating undefined entry' do
it 'creates a null entry' do it 'creates a null entry' do
entry = factory entry = factory
.with(value: nil) .with(value: nil)
.nullify! .undefine!
.create! .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 end
end end
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Ci::Config::Node::Null do describe Gitlab::Ci::Config::Node::Undefined do
let(:entry) { described_class.new(nil) } let(:entry) { described_class.new('some value') }
describe '#leaf?' do describe '#leaf?' do
it 'is leaf node' do it 'is leaf node' do
...@@ -16,8 +16,8 @@ describe Gitlab::Ci::Config::Node::Null do ...@@ -16,8 +16,8 @@ describe Gitlab::Ci::Config::Node::Null do
end end
describe '#value' do describe '#value' do
it 'returns nil' do it 'returns configured value' do
expect(entry.value).to be nil expect(entry.value).to eq 'some value'
end end
end 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