diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-05-06 08:47:19 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-05-19 22:01:53 +0200 |
commit | 9fd6f1b6009410cee0d0d7db8703ad64701db62b (patch) | |
tree | 4789962315d4635cc2094c08489a1a76478b7e12 /app | |
parent | 2ee24bd9ece394269c006f9762d3fa5e16876949 (diff) | |
download | gitlab-ce-9fd6f1b6009410cee0d0d7db8703ad64701db62b.tar.gz |
Improve displaying validation messages for runner
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/runners_controller.rb | 1 | ||||
-rw-r--r-- | app/models/ci/runner.rb | 10 | ||||
-rw-r--r-- | app/views/projects/runners/edit.html.haml | 6 |
3 files changed, 13 insertions, 4 deletions
diff --git a/app/controllers/projects/runners_controller.rb b/app/controllers/projects/runners_controller.rb index 12172b47520..0b4fa572501 100644 --- a/app/controllers/projects/runners_controller.rb +++ b/app/controllers/projects/runners_controller.rb @@ -20,7 +20,6 @@ class Projects::RunnersController < Projects::ApplicationController if @runner.update_attributes(runner_params) redirect_to runner_path(@runner), notice: 'Runner was successfully updated.' else - flash[:alert] = @runner.errors.full_messages.to_sentence render 'edit' end end diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index b1227d72405..f5813589492 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -27,9 +27,9 @@ module Ci 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!') + unless runner.has_tags? || runner.run_untagged? + errors.add(:tags_list, + 'can not be empty when runner is not allowed to pick untagged jobs') end end @@ -103,5 +103,9 @@ module Ci def short_sha token[0...8] if token end + + def has_tags? + tag_list.any? + end end end diff --git a/app/views/projects/runners/edit.html.haml b/app/views/projects/runners/edit.html.haml index 771947d7908..a5cfa9a8da9 100644 --- a/app/views/projects/runners/edit.html.haml +++ b/app/views/projects/runners/edit.html.haml @@ -1,5 +1,11 @@ - page_title "Edit", "#{@runner.description} ##{@runner.id}", "Runners" %h4 Runner ##{@runner.id} + +- if @runner.errors.any? + .error-message.js-errors + - @runner.errors.full_messages.each do |error| + %div= error + %hr = render 'form', runner: @runner, runner_form_url: runner_path(@runner) |