summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-02 16:43:42 -0700
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-02 16:43:42 -0700
commit3d02472ecd17599b614dabc2df2cb7c3ea13026f (patch)
tree2f97b4ce85e28323dc23b6da9d154fbcd77a89d9
parent66bbfc7f117135492d60c9e331ba347e5f2a2155 (diff)
downloadgitlab-ci-search-runners.tar.gz
Search runners by token or description on admin/runners pagesearch-runners
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/admin/runners_controller.rb4
-rw-r--r--app/models/runner.rb5
-rw-r--r--app/views/admin/runners/index.html.haml6
-rw-r--r--spec/features/admin/runners_spec.rb13
5 files changed, 27 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index e3d6c28..f99b6d7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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