Add image configuration entry to new ci config

This commit is contained in:
Grzegorz Bizon 2016-06-21 11:47:05 +02:00
parent c91298d554
commit 8b550db33e
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,22 @@
module Gitlab
module Ci
class Config
module Node
##
# Entry that represents a Docker image.
#
class Image < Entry
include Validatable
validations do
validates :config, type: String
end
def value
@config
end
end
end
end
end
end

View File

@ -0,0 +1,46 @@
require 'spec_helper'
describe Gitlab::Ci::Config::Node::Image do
let(:entry) { described_class.new(config) }
describe 'validation' do
context 'when entry config value is correct' do
let(:config) { 'ruby:2.2' }
describe '#value' do
it 'returns image string' do
expect(entry.value).to eq 'ruby:2.2'
end
end
describe '#errors' do
it 'does not append errors' do
expect(entry.errors).to be_empty
end
end
describe '#valid?' do
it 'is valid' do
expect(entry).to be_valid
end
end
end
context 'when entry value is not correct' do
let(:config) { ['ruby:2.2'] }
describe '#errors' do
it 'saves errors' do
expect(entry.errors)
.to include 'Image config should be a string'
end
end
describe '#valid?' do
it 'is not valid' do
expect(entry).not_to be_valid
end
end
end
end
end