que-web 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 672166ccf3fefe35330d64b781e67e4e1068076e
4
- data.tar.gz: 7f7ef4053bc098ef284f86784945924bae920372
3
+ metadata.gz: 70f3a29ddd4f76bdfb0a2aa84d663874366639a4
4
+ data.tar.gz: e6887380327c8e50a8a4e3aeb682d4d7408c81f9
5
5
  SHA512:
6
- metadata.gz: 5bdf1e394129ed1091206499b50e976894786e59a7cc064b6e2d54e84143ff2c9dd520942809dc823fd4d39a60420c8b1340a3c9288e5a705b68bde6797c601f
7
- data.tar.gz: 42784229848c993f5c38ca09e2dc9a057c35a4a348aaccab84202edcff43a89ebde97448bb67901616a8753b80951a41e29916fb5d1dc1c3b8aa3a085997236a
6
+ metadata.gz: 90343c4a7898f6085ae331a3062006032ff299704431f6e255818b9325423c54902df5f52191574bd840617953e1b6a21477083ca7c47f8922c6cd82403e6025
7
+ data.tar.gz: e2b62a44728afe7c43c3d5f14fc873e3c090c792de35a589d7c1dc57df98b2bee8808bd61b88b6d4ed26cf9f4cf8a7ff25597e420fb10a0a3a78e9040a4698e1
data/lib/que/web.rb CHANGED
@@ -140,21 +140,6 @@ module Que
140
140
  Pager.new(page, PAGE_SIZE, record_count)
141
141
  end
142
142
 
143
- def search
144
- return '%' unless search_param.present?
145
- "%#{search_param}%"
146
- end
147
-
148
- def search_running(jobs)
149
- return jobs unless search_param.present?
150
- jobs.select { |job| job.job_class.include? search_param }
151
- end
152
-
153
- def search_param
154
- return unless params['search'].present?
155
- params['search'].gsub(/[^0-9A-Za-z:]/, '')
156
- end
157
-
158
143
  after { session[FLASH_KEY] = {} if @sweep_flash }
159
144
 
160
145
  module Helpers
@@ -167,10 +152,26 @@ module Que
167
152
  end
168
153
 
169
154
  def path_with_search(path)
170
- path += "?search=#{search_param}" if search_param.present?
155
+ path += "?search=#{search_param}" if search_param
171
156
  path
172
157
  end
173
158
 
159
+ def search
160
+ return '%' unless search_param
161
+ "%#{search_param}%"
162
+ end
163
+
164
+ def search_running(jobs)
165
+ return jobs unless search_param
166
+ jobs.select { |job| job.fetch('job_class').include? search_param }
167
+ end
168
+
169
+ def search_param
170
+ sanitised = (params['search'] || '').gsub(/[^0-9a-z:]i/, '')
171
+ return if sanitised.empty?
172
+ sanitised
173
+ end
174
+
174
175
  def active_class(pattern)
175
176
  if request.path.match pattern
176
177
  "active"
data/que-web.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "que-web"
7
- spec.version = "0.7.1"
7
+ spec.version = "0.7.2"
8
8
  spec.authors = ["Jason Staten"]
9
9
  spec.email = ["jstaten07@gmail.com"]
10
10
  spec.summary = %q{A web interface for the que queue}
data/spec/web_spec.rb CHANGED
@@ -1,8 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Que::Web::Helpers do
4
+ let(:search) { '' }
5
+ let(:params) { { 'search' => search } }
6
+
4
7
  subject do
5
- Class.new { include Que::Web::Helpers }.new
8
+ # Capture the params into an ivar so the params method block below captures it
9
+ params_to_use = params
10
+
11
+ Class.new do
12
+ include Que::Web::Helpers
13
+
14
+ define_method(:params) { params_to_use }
15
+ end.new
6
16
  end
7
17
 
8
18
  def error_job(last_error)
@@ -22,4 +32,44 @@ describe Que::Web::Helpers do
22
32
  subject.format_error(error_job('')).must_equal ''
23
33
  end
24
34
  end
35
+
36
+ describe '#search_running' do
37
+ let(:jobs) do
38
+ [
39
+ { 'job_class' => 'JobClassA' },
40
+ { 'job_class' => 'JobClassB' },
41
+ { 'job_class' => 'JobClassA2' },
42
+ { 'job_class' => 'JobClassC' }
43
+ ]
44
+ end
45
+
46
+ describe 'when the search param is not supplied' do
47
+ let(:params) { {} }
48
+
49
+ it 'returns all the jobs' do
50
+ subject.search_running(jobs).must_equal(jobs)
51
+ end
52
+ end
53
+
54
+ describe 'when the search param is blank' do
55
+ let(:search) { '' }
56
+
57
+ it 'returns all the jobs' do
58
+ subject.search_running(jobs).must_equal(jobs)
59
+ end
60
+ end
61
+
62
+ describe 'when the search param is present' do
63
+ let(:search) { 'A' }
64
+
65
+ it 'returns only the jobs whose class matches the search' do
66
+ subject.search_running(jobs).must_equal(
67
+ [
68
+ { 'job_class' => 'JobClassA' },
69
+ { 'job_class' => 'JobClassA2' }
70
+ ]
71
+ )
72
+ end
73
+ end
74
+ end
25
75
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: que-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Staten
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-02 00:00:00.000000000 Z
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: que