sidekiq-cron 0.4.4 → 0.4.5

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: 7b46a8aee85dbf5b066d34641a17f4f34ff7307f
4
- data.tar.gz: b3d6a7566616aaa7ac5489289f5972432027d5a2
3
+ metadata.gz: 27adf3b417616b5e594db892be3866efc4911387
4
+ data.tar.gz: 6e788c3f530ebf8a9ed62fe54da69dd3e18b07ac
5
5
  SHA512:
6
- metadata.gz: 2d4ef330692ca3f9ea1ca7c9784cec17d8b13b15364426c0b25d604bccf87b39e3bd6e2d1b6c7bd12a52661c8d9675f495ab8f36a8c58bc44960e8dd566a87ef
7
- data.tar.gz: 974512d9821df1ec95296be13cd51f4e5490f04eca4b65bc3be2e41756af4570cbde023e1c2a1020187a404507087b3a133173c03b79b8d8ff8a9fe0a04ba7fa
6
+ metadata.gz: 7cb4c353e7f151e6a9dd8c5749769550fffef3fd00f0d6944029560f73aaa68573b3425fa023a1526d8702ad9dd0bb8a077e53810e3b8d7bd73fd13a57f19f56
7
+ data.tar.gz: 6646a6b48f28907665b71b37307302b645a8c6fab980cde71612c6b081ee8c90b3f5d88ef199e9e579e9dea3ed7589dd29a42aab60283ee67ec84e0efe32c3bd
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'sidekiq', '>= 4.2.1'
4
- gem 'rufus-scheduler', '>= 2.0.24'
4
+ gem 'rufus-scheduler', '>= 3.3.0'
5
5
  gem 'redis-namespace', '>= 1.5.2'
6
6
 
7
7
  group :development do
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.4
1
+ 0.4.5
@@ -79,13 +79,13 @@ module Sidekiq
79
79
  end
80
80
 
81
81
  def enqueue_active_job(klass_const)
82
- klass_const.set(queue: @queue_name_with_prefix).perform_later(*@args)
82
+ klass_const.set(queue: @queue).perform_later(*@args)
83
83
 
84
84
  true
85
85
  end
86
86
 
87
87
  def enqueue_sidekiq_worker(klass_const)
88
- klass_const.set(queue: @queue_name_with_prefix).perform_async(*@args)
88
+ klass_const.set(queue: queue_name_with_prefix).perform_async(*@args)
89
89
 
90
90
  true
91
91
  end
@@ -306,7 +306,6 @@ module Sidekiq
306
306
  #Unknown class
307
307
  message_data.merge("queue"=>"default")
308
308
  end
309
-
310
309
  end
311
310
 
312
311
  #override queue if setted in config
@@ -518,7 +517,7 @@ module Sidekiq
518
517
  private
519
518
 
520
519
  def not_enqueued_after?(time)
521
- @last_enqueue_time.nil? || @last_enqueue_time < last_time(time)
520
+ @last_enqueue_time.nil? || @last_enqueue_time.to_i < last_time(time).to_i
522
521
  end
523
522
 
524
523
  # Try parsing inbound args into an array.
@@ -544,7 +543,7 @@ module Sidekiq
544
543
 
545
544
  def not_past_scheduled_time?(current_time)
546
545
  last_cron_time = Rufus::Scheduler::CronLine.new(@cron).previous_time(current_time)
547
- return false if (current_time - last_cron_time) > 60
546
+ return false if (current_time.to_i - last_cron_time.to_i) > 60
548
547
  true
549
548
  end
550
549
 
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: sidekiq-cron 0.4.4 ruby lib
5
+ # stub: sidekiq-cron 0.4.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "sidekiq-cron".freeze
9
- s.version = "0.4.4"
9
+ s.version = "0.4.5"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
@@ -256,6 +256,30 @@ describe "Cron Job" do
256
256
  end
257
257
  end
258
258
 
259
+ describe '#sidekiq_worker_message settings overwrite queue name' do
260
+ before do
261
+ @args = {
262
+ name: 'Test',
263
+ cron: '* * * * *',
264
+ queue: 'super_queue',
265
+ klass: 'CronTestClassWithQueue',
266
+ args: { foo: 'bar' }
267
+ }
268
+ @job = Sidekiq::Cron::Job.new(@args)
269
+ end
270
+
271
+ it 'should return valid payload for Sidekiq::Client with overwrite queue name' do
272
+ payload = {
273
+ "retry" => false,
274
+ "backtrace"=>true,
275
+ "queue" => "super_queue",
276
+ "class" => "CronTestClassWithQueue",
277
+ "args" => [{:foo=>"bar"}]
278
+ }
279
+ assert_equal @job.sidekiq_worker_message, payload
280
+ end
281
+ end
282
+
259
283
  describe '#active_job_message' do
260
284
  before do
261
285
  SecureRandom.stubs(:uuid).returns('XYZ')
@@ -911,5 +935,37 @@ describe "Cron Job" do
911
935
  assert_equal Sidekiq::Cron::Job.all.size, 2, "Should have 2 jobs after load"
912
936
  end
913
937
  end
938
+
939
+ describe "from array with queue_name" do
940
+ before do
941
+ @jobs_array = [
942
+ {
943
+ 'name' => 'name_of_job',
944
+ 'class' => 'CronTestClassWithQueue',
945
+ 'cron' => '1 * * * *',
946
+ 'args' => '(OPTIONAL) [Array or Hash]',
947
+ 'queue' => 'from_array'
948
+ }
949
+ ]
950
+ end
951
+
952
+ it "create new jobs and update old one with same settings" do
953
+ assert_equal Sidekiq::Cron::Job.all.size, 0, "Should have 0 jobs before load"
954
+ out = Sidekiq::Cron::Job.load_from_array @jobs_array
955
+ assert_equal out.size, 0, "should have 0 error"
956
+ assert_equal Sidekiq::Cron::Job.all.size, 1, "Should have 2 jobs after load"
957
+
958
+ payload = {
959
+ "retry" => false,
960
+ "backtrace"=>true,
961
+ "queue" => "from_array",
962
+ "class" => "CronTestClassWithQueue",
963
+ "args" => ['(OPTIONAL) [Array or Hash]']
964
+ }
965
+
966
+ assert_equal Sidekiq::Cron::Job.all.first.sidekiq_worker_message, payload
967
+ end
968
+
969
+ end
914
970
  end
915
971
  end
@@ -24,6 +24,14 @@ describe 'Cron web' do
24
24
  klass: "CronTestClass"
25
25
  }
26
26
 
27
+
28
+ @cron_args = {
29
+ name: "TesQueueNameOfCronJob",
30
+ cron: "*/2 * * * *",
31
+ klass: "CronQueueTestClass",
32
+ queue: "cron"
33
+ }
34
+
27
35
  end
28
36
 
29
37
  it 'display cron web' do
@@ -38,6 +46,7 @@ describe 'Cron web' do
38
46
 
39
47
  it 'display cron web with cron jobs table' do
40
48
  Sidekiq::Cron::Job.create(@args)
49
+
41
50
  get '/cron'
42
51
  assert_equal 200, last_response.status
43
52
  refute last_response.body.include?('No cron jobs found')
@@ -51,6 +60,10 @@ describe 'Cron web' do
51
60
  @job = Sidekiq::Cron::Job.new(@args.merge(status: "enabled"))
52
61
  @job.save
53
62
  @name = "TestNameOfCronJob"
63
+
64
+ @cron_job = Sidekiq::Cron::Job.new(@cron_args.merge(status: "enabled"))
65
+ @cron_job.save
66
+ @cron_job_name = "TesQueueNameOfCronJob"
54
67
  end
55
68
 
56
69
  it "disable and enable cron job" do
@@ -78,11 +91,19 @@ describe 'Cron web' do
78
91
  Sidekiq.redis do |conn|
79
92
  assert_equal 2, conn.llen("queue:default"), "Queue should have 2 job"
80
93
  end
94
+
95
+ #should enqueue to cron job queue
96
+ post "/cron/#{@cron_job_name}/enque"
97
+
98
+ Sidekiq.redis do |conn|
99
+ assert_equal 1, conn.llen("queue:cron"), "Queue should have 1 cron job"
100
+ end
81
101
  end
82
102
 
83
103
  it "destroy job" do
84
- assert_equal Sidekiq::Cron::Job.all.size, 1, "Should have 1 job"
104
+ assert_equal Sidekiq::Cron::Job.all.size, 2, "Should have 2 job"
85
105
  post "/cron/#{@name}/delete"
106
+ post "/cron/#{@cron_job_name}/delete"
86
107
  assert_equal Sidekiq::Cron::Job.all.size, 0, "Should have zero jobs"
87
108
  end
88
109
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Bartas
@@ -303,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
303
  version: '0'
304
304
  requirements: []
305
305
  rubyforge_project:
306
- rubygems_version: 2.6.6
306
+ rubygems_version: 2.4.5
307
307
  signing_key:
308
308
  specification_version: 4
309
309
  summary: Sidekiq Cron helps to add repeated scheduled jobs