Commit 63bd1f92 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix rubocop complains

parent c764b57f
...@@ -100,6 +100,29 @@ module Ci ...@@ -100,6 +100,29 @@ module Ci
end end
def validate! def validate!
validate_global!
@jobs.each do |name, job|
validate_job!(name, job)
end
true
end
def validate_job!(name, job)
validate_job_name!(name)
validate_job_keys!(name, job)
validate_job_types!(name, job)
validate_job_stage!(name, job) if job[:stage]
validate_job_cache!(name, job) if job[:cache]
validate_job_artifacts!(name, job) if job[:artifacts]
validate_job_dependencies!(name, job) if job[:dependencies]
end
private
def validate_global!
unless validate_array_of_strings(@before_script) unless validate_array_of_strings(@before_script)
raise ValidationError, "before_script should be an array of strings" raise ValidationError, "before_script should be an array of strings"
end end
...@@ -124,7 +147,10 @@ module Ci ...@@ -124,7 +147,10 @@ module Ci
raise ValidationError, "variables should be a map of key-valued strings" raise ValidationError, "variables should be a map of key-valued strings"
end end
if @cache validate_global_cache! if @cache
end
def validate_global_cache!
if @cache[:key] && !validate_string(@cache[:key]) if @cache[:key] && !validate_string(@cache[:key])
raise ValidationError, "cache:key parameter should be a string" raise ValidationError, "cache:key parameter should be a string"
end end
...@@ -138,26 +164,6 @@ module Ci ...@@ -138,26 +164,6 @@ module Ci
end end
end end
@jobs.each do |name, job|
validate_job!(name, job)
end
true
end
def validate_job!(name, job)
validate_job_name!(name)
validate_job_keys!(name, job)
validate_job_types!(name, job)
validate_job_stage!(name, job) if job[:stage]
validate_job_cache!(name, job) if job[:cache]
validate_job_artifacts!(name, job) if job[:artifacts]
validate_job_dependencies!(name, job) if job[:dependencies]
end
private
def validate_job_name!(name) def validate_job_name!(name)
if name.blank? || !validate_string(name) if name.blank? || !validate_string(name)
raise ValidationError, "job name should be non-empty string" raise ValidationError, "job name should be non-empty string"
......
...@@ -295,12 +295,12 @@ module Ci ...@@ -295,12 +295,12 @@ module Ci
describe "after_script" do describe "after_script" do
context "in global context" do context "in global context" do
let(:config) { let(:config) do
{ {
after_script: ["after_script"], after_script: ["after_script"],
test: { script: ["script"] } test: { script: ["script"] }
} }
} end
it "return after_script in options" do it "return after_script in options" do
expect(subject[:options][:after_script]).to eq(["after_script"]) expect(subject[:options][:after_script]).to eq(["after_script"])
......
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