sidekiq-cron 1.2.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,37 +1,39 @@
1
1
  require './test/test_helper'
2
2
 
3
- def app
4
- Sidekiq::Web
5
- end
6
-
7
3
  describe 'Cron web' do
8
4
  include Rack::Test::Methods
9
5
 
6
+ TOKEN = SecureRandom.base64(32).freeze
7
+
8
+ def app
9
+ Sidekiq::Web
10
+ end
11
+
10
12
  before do
13
+ env 'rack.session', { csrf: TOKEN }
14
+ env 'HTTP_X_CSRF_TOKEN', TOKEN
15
+ REDIS.with { |c| c.respond_to?(:redis) ? c.redis.flushdb : c.flushdb }
11
16
  Sidekiq.redis = REDIS
12
- Redis.current.flushdb
17
+ end
13
18
 
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
19
+ let(:job_name) { "TestNameOfCronJob" }
20
+ let(:cron_job_name) { "TesQueueNameOfCronJob" }
20
21
 
21
- @args = {
22
- name: "TestNameOfCronJob",
22
+ let(:args) do
23
+ {
24
+ name: job_name,
23
25
  cron: "*/2 * * * *",
24
26
  klass: "CronTestClass"
25
27
  }
28
+ end
26
29
 
27
-
28
- @cron_args = {
29
- name: "TesQueueNameOfCronJob",
30
+ let(:cron_args) do
31
+ {
32
+ name: cron_job_name,
30
33
  cron: "*/2 * * * *",
31
34
  klass: "CronQueueTestClass",
32
35
  queue: "cron"
33
36
  }
34
-
35
37
  end
36
38
 
37
39
  it 'display cron web' do
@@ -45,7 +47,7 @@ describe 'Cron web' do
45
47
  end
46
48
 
47
49
  it 'display cron web with cron jobs table' do
48
- Sidekiq::Cron::Job.create(@args)
50
+ Sidekiq::Cron::Job.create(args)
49
51
 
50
52
  get '/cron'
51
53
  assert_equal 200, last_response.status
@@ -55,27 +57,25 @@ describe 'Cron web' do
55
57
  end
56
58
 
57
59
  describe "work with cron job" do
58
-
59
60
  before do
60
- @job = Sidekiq::Cron::Job.new(@args.merge(status: "enabled"))
61
- @job.save
62
- @name = "TestNameOfCronJob"
61
+ @job = Sidekiq::Cron::Job.new(args.merge(status: "enabled"))
62
+ assert @job.save
63
63
 
64
- @cron_job = Sidekiq::Cron::Job.new(@cron_args.merge(status: "enabled"))
65
- @cron_job.save
66
- @cron_job_name = "TesQueueNameOfCronJob"
64
+ @cron_job = Sidekiq::Cron::Job.new(cron_args.merge(status: "enabled"))
65
+ assert @cron_job.save
67
66
  end
68
67
 
69
68
  it 'shows history of a cron job' do
70
69
  @job.enque!
71
- get "/cron/#{@name}"
70
+ get "/cron/#{job_name}"
72
71
 
73
72
  jid =
74
73
  Sidekiq.redis do |conn|
75
- history = conn.lrange Sidekiq::Cron::Job.jid_history_key(@name), 0, -1
74
+ history = conn.lrange Sidekiq::Cron::Job.jid_history_key(job_name), 0, -1
76
75
  Sidekiq.load_json(history.last)['jid']
77
76
  end
78
77
 
78
+ assert jid
79
79
  assert last_response.body.include?(jid)
80
80
  end
81
81
 
@@ -87,18 +87,18 @@ describe 'Cron web' do
87
87
 
88
88
  it "disable and enable all cron jobs" do
89
89
  post "/cron/__all__/disable"
90
- assert_equal Sidekiq::Cron::Job.find(@name).status, "disabled"
90
+ assert_equal Sidekiq::Cron::Job.find(job_name).status, "disabled"
91
91
 
92
92
  post "/cron/__all__/enable"
93
- assert_equal Sidekiq::Cron::Job.find(@name).status, "enabled"
93
+ assert_equal Sidekiq::Cron::Job.find(job_name).status, "enabled"
94
94
  end
95
95
 
96
96
  it "disable and enable cron job" do
97
- post "/cron/#{@name}/disable"
98
- assert_equal Sidekiq::Cron::Job.find(@name).status, "disabled"
97
+ post "/cron/#{job_name}/disable"
98
+ assert_equal Sidekiq::Cron::Job.find(job_name).status, "disabled"
99
99
 
100
- post "/cron/#{@name}/enable"
101
- assert_equal Sidekiq::Cron::Job.find(@name).status, "enabled"
100
+ post "/cron/#{job_name}/enable"
101
+ assert_equal Sidekiq::Cron::Job.find(job_name).status, "enabled"
102
102
  end
103
103
 
104
104
  it "enqueue all jobs" do
@@ -119,21 +119,21 @@ describe 'Cron web' do
119
119
  assert_equal 0, conn.llen("queue:default"), "Queue should have no jobs"
120
120
  end
121
121
 
122
- post "/cron/#{@name}/enque"
122
+ post "/cron/#{job_name}/enque"
123
123
 
124
124
  Sidekiq.redis do |conn|
125
125
  assert_equal 1, conn.llen("queue:default"), "Queue should have 1 job"
126
126
  end
127
127
 
128
128
  #should enqueue more times
129
- post "/cron/#{@name}/enque"
129
+ post "/cron/#{job_name}/enque"
130
130
 
131
131
  Sidekiq.redis do |conn|
132
132
  assert_equal 2, conn.llen("queue:default"), "Queue should have 2 job"
133
133
  end
134
134
 
135
135
  #should enqueue to cron job queue
136
- post "/cron/#{@cron_job_name}/enque"
136
+ post "/cron/#{cron_job_name}/enque"
137
137
 
138
138
  Sidekiq.redis do |conn|
139
139
  assert_equal 1, conn.llen("queue:cron"), "Queue should have 1 cron job"
@@ -142,8 +142,8 @@ describe 'Cron web' do
142
142
 
143
143
  it "destroy job" do
144
144
  assert_equal Sidekiq::Cron::Job.all.size, 2, "Should have 2 job"
145
- post "/cron/#{@name}/delete"
146
- post "/cron/#{@cron_job_name}/delete"
145
+ post "/cron/#{job_name}/delete"
146
+ post "/cron/#{cron_job_name}/delete"
147
147
  assert_equal Sidekiq::Cron::Job.all.size, 0, "Should have zero jobs"
148
148
  end
149
149
 
metadata CHANGED
@@ -1,281 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.5.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: 2020-04-03 00:00:00.000000000 Z
11
+ date: 2022-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: sidekiq
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 4.2.1
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 4.2.1
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: fugit
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '1.1'
19
+ version: '1'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '1.1'
26
+ version: '1'
41
27
  - !ruby/object:Gem::Dependency
42
- name: bundler
28
+ name: sidekiq
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
33
+ version: 4.2.1
34
+ type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: 4.2.1
55
41
  - !ruby/object:Gem::Dependency
56
- name: simplecov
42
+ name: minitest
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ">="
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '0'
47
+ version: '5.15'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ">="
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '0'
54
+ version: '5.15'
69
55
  - !ruby/object:Gem::Dependency
70
- name: redis-namespace
56
+ name: mocha
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - ">="
59
+ - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: 1.5.2
61
+ version: '1.14'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - ">="
66
+ - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: 1.5.2
68
+ version: '1.14'
83
69
  - !ruby/object:Gem::Dependency
84
- name: shoulda-context
70
+ name: redis-namespace
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - ">="
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
75
+ version: '1.8'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ">="
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: '1.8'
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.2'
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.2'
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
- - - ">="
228
- - !ruby/object:Gem::Version
229
- version: '0'
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - ">="
235
- - !ruby/object:Gem::Version
236
- version: '0'
237
- - !ruby/object:Gem::Dependency
238
- name: shotgun
239
- requirement: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - ">="
101
+ - - "~>"
242
102
  - !ruby/object:Gem::Version
243
- version: '0'
103
+ version: '1.1'
244
104
  type: :development
245
105
  prerelease: false
246
106
  version_requirements: !ruby/object:Gem::Requirement
247
107
  requirements:
248
- - - ">="
108
+ - - "~>"
249
109
  - !ruby/object:Gem::Version
250
- version: '0'
110
+ version: '1.1'
251
111
  - !ruby/object:Gem::Dependency
252
- name: guard
112
+ name: rake
253
113
  requirement: !ruby/object:Gem::Requirement
254
114
  requirements:
255
- - - ">="
115
+ - - "~>"
256
116
  - !ruby/object:Gem::Version
257
- version: '0'
117
+ version: '13.0'
258
118
  type: :development
259
119
  prerelease: false
260
120
  version_requirements: !ruby/object:Gem::Requirement
261
121
  requirements:
262
- - - ">="
122
+ - - "~>"
263
123
  - !ruby/object:Gem::Version
264
- version: '0'
124
+ version: '13.0'
265
125
  - !ruby/object:Gem::Dependency
266
- name: guard-minitest
126
+ name: simplecov
267
127
  requirement: !ruby/object:Gem::Requirement
268
128
  requirements:
269
- - - ">="
129
+ - - "~>"
270
130
  - !ruby/object:Gem::Version
271
- version: '0'
131
+ version: '0.21'
272
132
  type: :development
273
133
  prerelease: false
274
134
  version_requirements: !ruby/object:Gem::Requirement
275
135
  requirements:
276
- - - ">="
136
+ - - "~>"
277
137
  - !ruby/object:Gem::Version
278
- version: '0'
138
+ version: '0.21'
279
139
  description: Enables to set jobs to be run in specified time (using CRON notation)
280
140
  email: ondrej@bartas.cz
281
141
  executables: []
@@ -284,18 +144,11 @@ extra_rdoc_files:
284
144
  - LICENSE.txt
285
145
  - README.md
286
146
  files:
287
- - ".document"
288
- - ".travis.yml"
289
147
  - Changes.md
290
- - Dockerfile
291
148
  - Gemfile
292
149
  - LICENSE.txt
293
150
  - README.md
294
151
  - Rakefile
295
- - VERSION
296
- - config.ru
297
- - docker-compose.yml
298
- - examples/web-cron-ui.png
299
152
  - lib/sidekiq-cron.rb
300
153
  - lib/sidekiq/cron.rb
301
154
  - lib/sidekiq/cron/job.rb
@@ -303,14 +156,14 @@ files:
303
156
  - lib/sidekiq/cron/locales/de.yml
304
157
  - lib/sidekiq/cron/locales/en.yml
305
158
  - lib/sidekiq/cron/locales/ja.yml
159
+ - lib/sidekiq/cron/locales/pt.yml
306
160
  - lib/sidekiq/cron/locales/ru.yml
307
161
  - lib/sidekiq/cron/locales/zh-CN.yml
308
162
  - lib/sidekiq/cron/poller.rb
309
163
  - lib/sidekiq/cron/support.rb
164
+ - lib/sidekiq/cron/version.rb
310
165
  - lib/sidekiq/cron/views/cron.erb
311
- - lib/sidekiq/cron/views/cron.slim
312
166
  - lib/sidekiq/cron/views/cron_show.erb
313
- - lib/sidekiq/cron/views/cron_show.slim
314
167
  - lib/sidekiq/cron/web.rb
315
168
  - lib/sidekiq/cron/web_extension.rb
316
169
  - sidekiq-cron.gemspec
@@ -319,7 +172,7 @@ files:
319
172
  - test/unit/job_test.rb
320
173
  - test/unit/poller_test.rb
321
174
  - test/unit/web_extension_test.rb
322
- homepage: http://github.com/ondrejbartas/sidekiq-cron
175
+ homepage: https://github.com/ondrejbartas/sidekiq-cron
323
176
  licenses:
324
177
  - MIT
325
178
  metadata: {}
@@ -331,16 +184,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
331
184
  requirements:
332
185
  - - ">="
333
186
  - !ruby/object:Gem::Version
334
- version: '0'
187
+ version: '2.6'
335
188
  required_rubygems_version: !ruby/object:Gem::Requirement
336
189
  requirements:
337
190
  - - ">="
338
191
  - !ruby/object:Gem::Version
339
192
  version: '0'
340
193
  requirements: []
341
- rubyforge_project:
342
- rubygems_version: 2.5.2.3
194
+ rubygems_version: 3.1.4
343
195
  signing_key:
344
196
  specification_version: 4
345
- summary: Sidekiq Cron helps to add repeated scheduled jobs
197
+ summary: Sidekiq-Cron helps to add repeated scheduled jobs
346
198
  test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.6
4
- - 2.5
5
- - 2.4
6
- - 2.3
7
- - 2.2
8
- services:
9
- - redis-server
10
- branches:
11
- only:
12
- - master
13
- notifications:
14
- email:
15
- recipients:
16
- - ondrej@bartas.cz
17
- env:
18
- travis: 'yes'
data/Dockerfile DELETED
@@ -1,32 +0,0 @@
1
- FROM ruby:2.4
2
- MAINTAINER Joao Serra <joaopfserra@gmail.com>
3
-
4
- RUN apt-get update && \
5
- apt-get install -y --force-yes \
6
- curl \
7
- git \
8
- wget \
9
- libpq-dev && \
10
- apt-get autoremove -y --force-yes && \
11
- apt-get clean && \
12
- rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
13
-
14
- ENV DOCKERIZE_VERSION v0.2.0
15
- RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
16
- && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
17
-
18
- RUN gem install bundler
19
-
20
- ENV APP_HOME /sidekiq-cron
21
- RUN mkdir $APP_HOME
22
- WORKDIR $APP_HOME
23
-
24
- ADD Gemfile* $APP_HOME/
25
-
26
- ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \
27
- BUNDLE_JOBS=2 \
28
- BUNDLE_PATH=/bundle
29
-
30
- RUN bundle install
31
-
32
- ADD . $APP_HOME
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.2.0
data/config.ru DELETED
@@ -1,14 +0,0 @@
1
- require 'sidekiq'
2
-
3
- Sidekiq.configure_client do |config|
4
- config.redis = { :size => 1 }
5
- end
6
-
7
- require 'sidekiq/web'
8
-
9
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
10
- $LOAD_PATH.unshift(File.dirname(__FILE__))
11
-
12
- require 'sidekiq-cron'
13
-
14
- run Sidekiq::Web
data/docker-compose.yml DELETED
@@ -1,23 +0,0 @@
1
- version: '2'
2
- services:
3
- common:
4
- build:
5
- context: .
6
- image: sidekiq-cron-test
7
- environment: &environment
8
- - REDIS_URL=redis://redis.test:6379/0
9
- dns:
10
- - 8.8.8.8
11
- - 8.8.4.4
12
- redis:
13
- image: redis
14
- tests:
15
- image: sidekiq-cron-test
16
- environment: *environment
17
- links:
18
- - redis:redis.test
19
- depends_on:
20
- - common
21
- command: dockerize -wait tcp://redis.test:6379 -timeout 60s bundle exec rake test
22
- volumes:
23
- - .:/sidekiq-cron
Binary file