sidekiq-cron 1.0.4 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,37 +1,40 @@
1
1
  require './test/test_helper'
2
-
3
- def app
4
- Sidekiq::Web
5
- end
2
+ require 'sidekiq/web'
6
3
 
7
4
  describe 'Cron web' do
8
5
  include Rack::Test::Methods
9
6
 
7
+ TOKEN = SecureRandom.base64(32).freeze
8
+
9
+ def app
10
+ Sidekiq::Web
11
+ end
12
+
10
13
  before do
14
+ env 'rack.session', { csrf: TOKEN }
15
+ env 'HTTP_X_CSRF_TOKEN', TOKEN
16
+ REDIS.with { |c| c.respond_to?(:redis) ? c.redis.flushdb : c.flushdb }
11
17
  Sidekiq.redis = REDIS
12
- Sidekiq.redis {|c| c.flushdb }
18
+ end
13
19
 
14
- #clear all previous saved data from redis
15
- Sidekiq.redis do |conn|
16
- conn.keys("cron_job*").each do |key|
17
- conn.del(key)
18
- end
19
- end
20
+ let(:job_name) { "TestNameOfCronJob" }
21
+ let(:cron_job_name) { "TesQueueNameOfCronJob" }
20
22
 
21
- @args = {
22
- name: "TestNameOfCronJob",
23
+ let(:args) do
24
+ {
25
+ name: job_name,
23
26
  cron: "*/2 * * * *",
24
27
  klass: "CronTestClass"
25
28
  }
29
+ end
26
30
 
27
-
28
- @cron_args = {
29
- name: "TesQueueNameOfCronJob",
31
+ let(:cron_args) do
32
+ {
33
+ name: cron_job_name,
30
34
  cron: "*/2 * * * *",
31
35
  klass: "CronQueueTestClass",
32
36
  queue: "cron"
33
37
  }
34
-
35
38
  end
36
39
 
37
40
  it 'display cron web' do
@@ -45,7 +48,7 @@ describe 'Cron web' do
45
48
  end
46
49
 
47
50
  it 'display cron web with cron jobs table' do
48
- Sidekiq::Cron::Job.create(@args)
51
+ Sidekiq::Cron::Job.create(args)
49
52
 
50
53
  get '/cron'
51
54
  assert_equal 200, last_response.status
@@ -55,31 +58,48 @@ describe 'Cron web' do
55
58
  end
56
59
 
57
60
  describe "work with cron job" do
58
-
59
61
  before do
60
- @job = Sidekiq::Cron::Job.new(@args.merge(status: "enabled"))
61
- @job.save
62
- @name = "TestNameOfCronJob"
62
+ @job = Sidekiq::Cron::Job.new(args.merge(status: "enabled"))
63
+ assert @job.save
64
+
65
+ @cron_job = Sidekiq::Cron::Job.new(cron_args.merge(status: "enabled"))
66
+ assert @cron_job.save
67
+ end
68
+
69
+ it 'shows history of a cron job' do
70
+ @job.enque!
71
+ get "/cron/#{job_name}"
72
+
73
+ jid =
74
+ Sidekiq.redis do |conn|
75
+ history = conn.lrange Sidekiq::Cron::Job.jid_history_key(job_name), 0, -1
76
+ Sidekiq.load_json(history.last)['jid']
77
+ end
78
+
79
+ assert jid
80
+ assert last_response.body.include?(jid)
81
+ end
82
+
83
+ it 'redirects to cron path when name not found' do
84
+ get '/cron/some-fake-name'
63
85
 
64
- @cron_job = Sidekiq::Cron::Job.new(@cron_args.merge(status: "enabled"))
65
- @cron_job.save
66
- @cron_job_name = "TesQueueNameOfCronJob"
86
+ assert_match %r{\/cron\z}, last_response['Location']
67
87
  end
68
88
 
69
89
  it "disable and enable all cron jobs" do
70
90
  post "/cron/__all__/disable"
71
- assert_equal Sidekiq::Cron::Job.find(@name).status, "disabled"
91
+ assert_equal Sidekiq::Cron::Job.find(job_name).status, "disabled"
72
92
 
73
93
  post "/cron/__all__/enable"
74
- assert_equal Sidekiq::Cron::Job.find(@name).status, "enabled"
94
+ assert_equal Sidekiq::Cron::Job.find(job_name).status, "enabled"
75
95
  end
76
96
 
77
97
  it "disable and enable cron job" do
78
- post "/cron/#{@name}/disable"
79
- assert_equal Sidekiq::Cron::Job.find(@name).status, "disabled"
98
+ post "/cron/#{job_name}/disable"
99
+ assert_equal Sidekiq::Cron::Job.find(job_name).status, "disabled"
80
100
 
81
- post "/cron/#{@name}/enable"
82
- assert_equal Sidekiq::Cron::Job.find(@name).status, "enabled"
101
+ post "/cron/#{job_name}/enable"
102
+ assert_equal Sidekiq::Cron::Job.find(job_name).status, "enabled"
83
103
  end
84
104
 
85
105
  it "enqueue all jobs" do
@@ -100,21 +120,21 @@ describe 'Cron web' do
100
120
  assert_equal 0, conn.llen("queue:default"), "Queue should have no jobs"
101
121
  end
102
122
 
103
- post "/cron/#{@name}/enque"
123
+ post "/cron/#{job_name}/enque"
104
124
 
105
125
  Sidekiq.redis do |conn|
106
126
  assert_equal 1, conn.llen("queue:default"), "Queue should have 1 job"
107
127
  end
108
128
 
109
129
  #should enqueue more times
110
- post "/cron/#{@name}/enque"
130
+ post "/cron/#{job_name}/enque"
111
131
 
112
132
  Sidekiq.redis do |conn|
113
133
  assert_equal 2, conn.llen("queue:default"), "Queue should have 2 job"
114
134
  end
115
135
 
116
136
  #should enqueue to cron job queue
117
- post "/cron/#{@cron_job_name}/enque"
137
+ post "/cron/#{cron_job_name}/enque"
118
138
 
119
139
  Sidekiq.redis do |conn|
120
140
  assert_equal 1, conn.llen("queue:cron"), "Queue should have 1 cron job"
@@ -123,8 +143,8 @@ describe 'Cron web' do
123
143
 
124
144
  it "destroy job" do
125
145
  assert_equal Sidekiq::Cron::Job.all.size, 2, "Should have 2 job"
126
- post "/cron/#{@name}/delete"
127
- post "/cron/#{@cron_job_name}/delete"
146
+ post "/cron/#{job_name}/delete"
147
+ post "/cron/#{cron_job_name}/delete"
128
148
  assert_equal Sidekiq::Cron::Job.all.size, 0, "Should have zero jobs"
129
149
  end
130
150
 
metadata CHANGED
@@ -1,45 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Bartas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-15 00:00:00.000000000 Z
11
+ date: 2020-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sidekiq
14
+ name: fugit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.1
19
+ version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.1
26
+ version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: fugit
28
+ name: sidekiq
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.1'
33
+ version: 4.2.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.1'
40
+ version: 4.2.1
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: simplecov
56
+ name: mocha
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -80,176 +80,50 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.5.2
83
- - !ruby/object:Gem::Dependency
84
- name: shoulda-context
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: rack
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - ">="
87
+ - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '0'
89
+ version: '2.0'
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - ">="
94
+ - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: '2.0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: rack-test
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: jeweler
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: minitest
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: test-unit
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: sdoc
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: slim
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: sinatra
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
- - !ruby/object:Gem::Dependency
210
- name: mocha
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - ">="
214
- - !ruby/object:Gem::Version
215
- version: '0'
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - ">="
221
- - !ruby/object:Gem::Version
222
- version: '0'
223
- - !ruby/object:Gem::Dependency
224
- name: coveralls
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - ">="
101
+ - - "~>"
228
102
  - !ruby/object:Gem::Version
229
- version: '0'
103
+ version: '1.0'
230
104
  type: :development
231
105
  prerelease: false
232
106
  version_requirements: !ruby/object:Gem::Requirement
233
107
  requirements:
234
- - - ">="
108
+ - - "~>"
235
109
  - !ruby/object:Gem::Version
236
- version: '0'
110
+ version: '1.0'
237
111
  - !ruby/object:Gem::Dependency
238
- name: shotgun
112
+ name: rake
239
113
  requirement: !ruby/object:Gem::Requirement
240
114
  requirements:
241
- - - ">="
115
+ - - "~>"
242
116
  - !ruby/object:Gem::Version
243
- version: '0'
117
+ version: '13.0'
244
118
  type: :development
245
119
  prerelease: false
246
120
  version_requirements: !ruby/object:Gem::Requirement
247
121
  requirements:
248
- - - ">="
122
+ - - "~>"
249
123
  - !ruby/object:Gem::Version
250
- version: '0'
124
+ version: '13.0'
251
125
  - !ruby/object:Gem::Dependency
252
- name: guard
126
+ name: shoulda-context
253
127
  requirement: !ruby/object:Gem::Requirement
254
128
  requirements:
255
129
  - - ">="
@@ -263,7 +137,7 @@ dependencies:
263
137
  - !ruby/object:Gem::Version
264
138
  version: '0'
265
139
  - !ruby/object:Gem::Dependency
266
- name: guard-minitest
140
+ name: simplecov
267
141
  requirement: !ruby/object:Gem::Requirement
268
142
  requirements:
269
143
  - - ">="
@@ -285,14 +159,12 @@ extra_rdoc_files:
285
159
  - README.md
286
160
  files:
287
161
  - ".document"
288
- - ".travis.yml"
289
162
  - Changes.md
290
163
  - Dockerfile
291
164
  - Gemfile
292
165
  - LICENSE.txt
293
166
  - README.md
294
167
  - Rakefile
295
- - VERSION
296
168
  - config.ru
297
169
  - docker-compose.yml
298
170
  - examples/web-cron-ui.png
@@ -307,8 +179,11 @@ files:
307
179
  - lib/sidekiq/cron/locales/zh-CN.yml
308
180
  - lib/sidekiq/cron/poller.rb
309
181
  - lib/sidekiq/cron/support.rb
182
+ - lib/sidekiq/cron/version.rb
310
183
  - lib/sidekiq/cron/views/cron.erb
311
184
  - lib/sidekiq/cron/views/cron.slim
185
+ - lib/sidekiq/cron/views/cron_show.erb
186
+ - lib/sidekiq/cron/views/cron_show.slim
312
187
  - lib/sidekiq/cron/web.rb
313
188
  - lib/sidekiq/cron/web_extension.rb
314
189
  - sidekiq-cron.gemspec
@@ -317,7 +192,7 @@ files:
317
192
  - test/unit/job_test.rb
318
193
  - test/unit/poller_test.rb
319
194
  - test/unit/web_extension_test.rb
320
- homepage: http://github.com/ondrejbartas/sidekiq-cron
195
+ homepage: https://github.com/ondrejbartas/sidekiq-cron
321
196
  licenses:
322
197
  - MIT
323
198
  metadata: {}
@@ -329,15 +204,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
329
204
  requirements:
330
205
  - - ">="
331
206
  - !ruby/object:Gem::Version
332
- version: '0'
207
+ version: '2.5'
333
208
  required_rubygems_version: !ruby/object:Gem::Requirement
334
209
  requirements:
335
210
  - - ">="
336
211
  - !ruby/object:Gem::Version
337
212
  version: '0'
338
213
  requirements: []
339
- rubyforge_project:
340
- rubygems_version: 2.5.2.1
214
+ rubygems_version: 3.0.3.1
341
215
  signing_key:
342
216
  specification_version: 4
343
217
  summary: Sidekiq Cron helps to add repeated scheduled jobs
data/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.5.0
4
- - 2.4.3
5
- - 2.3.6
6
- - 2.2.9
7
- services:
8
- - redis-server
9
- branches:
10
- only:
11
- - master
12
- notifications:
13
- email:
14
- recipients:
15
- - ondrej@bartas.cz
16
- env:
17
- travis: 'yes'
18
- matrix:
19
- allow_failures:
20
- - rvm: jruby-19mode
21
- - rvm: rbx-19mode
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.4