BigW Consortium Gitlab

Commit a00520b1 by Lin Jen-Shin

Restore Unspecified and we could discuss later

parent dc3a41f4
...@@ -37,7 +37,9 @@ module Gitlab ...@@ -37,7 +37,9 @@ module Gitlab
# See issue #18775. # See issue #18775.
# #
if @value.nil? if @value.nil?
Entry::Unspecified.new(
fabricate_unspecified fabricate_unspecified
)
else else
fabricate(@entry, @value) fabricate(@entry, @value)
end end
...@@ -54,7 +56,7 @@ module Gitlab ...@@ -54,7 +56,7 @@ module Gitlab
fabricate(Entry::Undefined) fabricate(Entry::Undefined)
else else
fabricate(@entry, @entry.default) fabricate(@entry, @entry.default)
end.tap(&:unspecify) end
end end
def fabricate(entry, value = nil) def fabricate(entry, value = nil)
......
...@@ -15,7 +15,6 @@ module Gitlab ...@@ -15,7 +15,6 @@ module Gitlab
@config = config @config = config
@metadata = metadata @metadata = metadata
@entries = {} @entries = {}
@specified = true
@validator = self.class.validator.new(self) @validator = self.class.validator.new(self)
@validator.validate(:new) @validator.validate(:new)
...@@ -63,12 +62,8 @@ module Gitlab ...@@ -63,12 +62,8 @@ module Gitlab
end end
end end
def unspecify
@specified = false
end
def specified? def specified?
@specified true
end end
def relevant? def relevant?
...@@ -76,18 +71,8 @@ module Gitlab ...@@ -76,18 +71,8 @@ module Gitlab
end end
def inspect def inspect
val = if leaf? val = leaf? ? config : descendants
config unspecified = specified? ? '' : '(unspecified) '
else
descendants
end
unspecified = if specified?
''
else
'(unspecified) '
end
"#<#{self.class.name} #{unspecified}{#{key}: #{val.inspect}}>" "#<#{self.class.name} #{unspecified}{#{key}: #{val.inspect}}>"
end 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