Skip to content
Snippets Groups Projects
Commit 3d02472e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Search runners by token or description on admin/runners page

parent 66bbfc7f
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment