From d7e125116124b9c08c27b4a02f4738619db1d2f5 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon <grzesiek.bizon@gmail.com> Date: Thu, 9 Jun 2016 14:59:59 +0200 Subject: [PATCH] Rename method that returns allowed nodes in Ci config --- lib/gitlab/ci/config/node/configurable.rb | 2 +- lib/gitlab/ci/config/node/entry.rb | 14 +++++++------- spec/lib/gitlab/ci/config/node/global_spec.rb | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/gitlab/ci/config/node/configurable.rb b/lib/gitlab/ci/config/node/configurable.rb index d3ed72649bc..cf065c7f6fe 100644 --- a/lib/gitlab/ci/config/node/configurable.rb +++ b/lib/gitlab/ci/config/node/configurable.rb @@ -24,7 +24,7 @@ module Gitlab end end - def keys + def allowed_nodes self.class.nodes || {} end diff --git a/lib/gitlab/ci/config/node/entry.rb b/lib/gitlab/ci/config/node/entry.rb index 7d7e6f26cbd..19fc997297a 100644 --- a/lib/gitlab/ci/config/node/entry.rb +++ b/lib/gitlab/ci/config/node/entry.rb @@ -28,7 +28,7 @@ module Gitlab end def compose! - keys.each do |key, entry| + allowed_nodes.each do |key, entry| add_node(key, entry) end end @@ -46,23 +46,23 @@ module Gitlab end def leaf? - keys.none? + allowed_nodes.none? end def has_config? @value.is_a?(Hash) end - def keys - {} - end - def errors @errors + nodes.map(&:errors).flatten end + def allowed_nodes + {} + end + def method_missing(name, *args) - super unless keys.has_key?(name) + super unless allowed_nodes.has_key?(name) raise InvalidError unless valid? @nodes[name].try(:value) diff --git a/spec/lib/gitlab/ci/config/node/global_spec.rb b/spec/lib/gitlab/ci/config/node/global_spec.rb index 9cbd62cbf60..1a51528336b 100644 --- a/spec/lib/gitlab/ci/config/node/global_spec.rb +++ b/spec/lib/gitlab/ci/config/node/global_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' describe Gitlab::Ci::Config::Node::Global do let(:global) { described_class.new(hash) } - describe '#keys' do + describe '#allowed_nodes' do it 'can contain global config keys' do - expect(global.keys).to include :before_script + expect(global.allowed_nodes).to include :before_script end it 'returns a hash' do - expect(global.keys).to be_a Hash + expect(global.allowed_nodes).to be_a Hash end end -- GitLab