Commit 9fd6f1b6 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve displaying validation messages for runner

parent 2ee24bd9
...@@ -20,7 +20,6 @@ class Projects::RunnersController < Projects::ApplicationController ...@@ -20,7 +20,6 @@ class Projects::RunnersController < Projects::ApplicationController
if @runner.update_attributes(runner_params) if @runner.update_attributes(runner_params)
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.' redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
else else
flash[:alert] = @runner.errors.full_messages.to_sentence
render 'edit' render 'edit'
end end
end end
......
...@@ -27,9 +27,9 @@ module Ci ...@@ -27,9 +27,9 @@ module Ci
end end
validate do |runner| validate do |runner|
if runner.tag_list.empty? && !runner.run_untagged? unless runner.has_tags? || runner.run_untagged?
errors.add(:tags_errors, errors.add(:tags_list,
'Runner without tags must be able to pick untagged jobs!') 'can not be empty when runner is not allowed to pick untagged jobs')
end end
end end
...@@ -103,5 +103,9 @@ module Ci ...@@ -103,5 +103,9 @@ module Ci
def short_sha def short_sha
token[0...8] if token token[0...8] if token
end end
def has_tags?
tag_list.any?
end
end end
end end
- page_title "Edit", "#{@runner.description} ##{@runner.id}", "Runners" - page_title "Edit", "#{@runner.description} ##{@runner.id}", "Runners"
%h4 Runner ##{@runner.id} %h4 Runner ##{@runner.id}
- if @runner.errors.any?
.error-message.js-errors
- @runner.errors.full_messages.each do |error|
%div= error
%hr %hr
= render 'form', runner: @runner, runner_form_url: runner_path(@runner) = render 'form', runner: @runner, runner_form_url: runner_path(@runner)
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