diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-02 16:43:42 -0700 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-02 16:43:42 -0700 |
commit | 3d02472ecd17599b614dabc2df2cb7c3ea13026f (patch) | |
tree | 2f97b4ce85e28323dc23b6da9d154fbcd77a89d9 | |
parent | 66bbfc7f117135492d60c9e331ba347e5f2a2155 (diff) | |
download | gitlab-ci-search-runners.tar.gz |
Search runners by token or description on admin/runners pagesearch-runners
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/admin/runners_controller.rb | 4 | ||||
-rw-r--r-- | app/models/runner.rb | 5 | ||||
-rw-r--r-- | app/views/admin/runners/index.html.haml | 6 | ||||
-rw-r--r-- | spec/features/admin/runners_spec.rb | 13 |
5 files changed, 27 insertions, 2 deletions
@@ -4,6 +4,7 @@ v7.10.0 - Fix GitLab and CI projects collision - Events for admin - Events per projects + - Search for runners in admin area v7.9.2 - [Security] Already existing projects should not be served by shared runners diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb index 41ee5b8..fd1b6b2 100644 --- a/app/controllers/admin/runners_controller.rb +++ b/app/controllers/admin/runners_controller.rb @@ -2,7 +2,9 @@ class Admin::RunnersController < Admin::ApplicationController before_filter :runner, except: :index def index - @runners = Runner.page(params[:page]).per(30) + @runners = Runner.all + @runners = @runners.search(params[:search]) if params[:search].present? + @runners = @runners.page(params[:page]).per(30) end def show diff --git a/app/models/runner.rb b/app/models/runner.rb index ed70097..bfd5a54 100644 --- a/app/models/runner.rb +++ b/app/models/runner.rb @@ -28,6 +28,11 @@ class Runner < ActiveRecord::Base acts_as_taggable + def self.search(query) + where('LOWER(runners.token) LIKE :query OR LOWER(runners.description) like :query', + query: "%#{query.try(:downcase)}%") + end + def set_default_values self.token = SecureRandom.hex(15) if self.token.blank? end diff --git a/app/views/admin/runners/index.html.haml b/app/views/admin/runners/index.html.haml index abbcf8f..869561f 100644 --- a/app/views/admin/runners/index.html.haml +++ b/app/views/admin/runners/index.html.haml @@ -31,7 +31,11 @@ %span.label.label-danger paused \- runner will not receive any new build - +.append-bottom-20 + = form_tag admin_runners_path, class: 'form-inline', method: :get do + .form-group + = search_field_tag :search, params[:search], class: 'form-control', placeholder: 'Runner description or token' + = submit_tag 'Search', class: 'btn' %table.table %thead diff --git a/spec/features/admin/runners_spec.rb b/spec/features/admin/runners_spec.rb index 5fe1130..a966aee 100644 --- a/spec/features/admin/runners_spec.rb +++ b/spec/features/admin/runners_spec.rb @@ -16,6 +16,19 @@ describe "Admin Runners" do it { page.has_text? "Manage Runners" } it { page.has_text? "To register a new runner" } + + describe 'search' do + before do + FactoryGirl.create :runner, description: 'foo' + FactoryGirl.create :runner, description: 'bar' + + fill_in 'search', with: 'foo' + click_button 'Search' + end + + it { page.should have_content("foo") } + it { page.should_not have_content("bar") } + end end describe "GET /admin/runners/:id" do |