Commit a00520b1 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Restore Unspecified and we could discuss later

Also feedback in:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9666/diffs#note_24608283
parent dc3a41f4
......@@ -37,7 +37,9 @@ module Gitlab
# See issue #18775.
#
if @value.nil?
Entry::Unspecified.new(
fabricate_unspecified
)
else
fabricate(@entry, @value)
end
......@@ -54,7 +56,7 @@ module Gitlab
fabricate(Entry::Undefined)
else
fabricate(@entry, @entry.default)
end.tap(&:unspecify)
end
end
def fabricate(entry, value = nil)
......
......@@ -15,7 +15,6 @@ module Gitlab
@config = config
@metadata = metadata
@entries = {}
@specified = true
@validator = self.class.validator.new(self)
@validator.validate(:new)
......@@ -63,12 +62,8 @@ module Gitlab
end
end
def unspecify
@specified = false
end
def specified?
@specified
true
end
def relevant?
......@@ -76,18 +71,8 @@ module Gitlab
end
def inspect
val = if leaf?
config
else
descendants
end
unspecified = if specified?
''
else
'(unspecified) '
end
val = leaf? ? config : descendants
unspecified = specified? ? '' : '(unspecified) '
"#<#{self.class.name} #{unspecified}{#{key}: #{val.inspect}}>"
end
......
module Gitlab
module Ci
class Config
module Entry
##
# This class represents an unspecified entry.
#
# It decorates original entry adding method that indicates it is
# unspecified.
#
class Unspecified < SimpleDelegator
def specified?
false
end
end
end
end
end
end
require 'spec_helper'
describe Gitlab::Ci::Config::Entry::Unspecified do
let(:unspecified) { described_class.new(entry) }
let(:entry) { spy('Entry') }
describe '#valid?' do
it 'delegates method to entry' do
expect(unspecified.valid?).to eq entry
end
end
describe '#errors' do
it 'delegates method to entry' do
expect(unspecified.errors).to eq entry
end
end
describe '#value' do
it 'delegates method to entry' do
expect(unspecified.value).to eq entry
end
end
describe '#specified?' do
it 'is always false' do
allow(entry).to receive(:specified?).and_return(true)
expect(unspecified.specified?).to be false
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