Commit dd8e9e2d authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add custom validator to runner model

parent 9129c37c
......@@ -20,7 +20,8 @@ class Projects::RunnersController < Projects::ApplicationController
if @runner.update_attributes(runner_params)
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
else
redirect_to runner_path(@runner), alert: 'Runner was not updated.'
flash[:alert] = @runner.errors.full_messages.to_sentence
render 'edit'
end
end
......
......@@ -26,6 +26,13 @@ module Ci
.where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id)
end
validate do |runner|
if runner.tag_list.empty? && !runner.run_untagged?
errors.add(:tags_errors,
'Runner without tags must be able to pick untagged jobs!')
end
end
acts_as_taggable
# Searches for runners matching the given query.
......
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