resque-scheduler 2.0.0.d → 2.0.0.e

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of resque-scheduler might be problematic. Click here for more details.

@@ -80,4 +80,14 @@ context "scheduling jobs with arguments" do
80
80
  SomeIvarJob.expects(:perform).once.with('first_key' => {'second_key' => 'value'})
81
81
  Resque.reserve('ivar').perform
82
82
  end
83
+
84
+ test "poll_sleep_amount defaults to 5" do
85
+ assert_equal 5, Resque::Scheduler.poll_sleep_amount
86
+ end
87
+
88
+ test "poll_sleep_amount is settable" do
89
+ Resque::Scheduler.poll_sleep_amount = 1
90
+ assert_equal 1, Resque::Scheduler.poll_sleep_amount
91
+ end
92
+
83
93
  end
@@ -31,10 +31,10 @@ class Resque::SchedulerTest < Test::Unit::TestCase
31
31
  end
32
32
 
33
33
  def test_enqueue_from_config_puts_stuff_in_the_resque_queue
34
- Resque::Job.stubs(:create).once.returns(true).with(:ivar, 'SomeIvarJob', '/tmp')
34
+ Resque::Job.stubs(:create).once.returns(true).with(:ivar, SomeIvarJob, '/tmp')
35
35
  Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp")
36
36
  end
37
-
37
+
38
38
  def test_enqueue_from_config_with_custom_class_job_in_the_resque_queue
39
39
  FakeJob.stubs(:scheduled).once.returns(true).with(:ivar, 'SomeIvarJob', '/tmp')
40
40
  Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'SomeIvarJob', 'custom_job_class' => 'Resque::SchedulerTest::FakeJob', 'args' => "/tmp")
@@ -78,6 +78,25 @@ class Resque::SchedulerTest < Test::Unit::TestCase
78
78
  assert_equal(1, Resque::Scheduler.rufus_scheduler.all_jobs.size)
79
79
  end
80
80
 
81
+ def test_enqueue_constantizes
82
+ # The job should be loaded, since a missing rails_env means ALL envs.
83
+ ENV['RAILS_ENV'] = 'production'
84
+ config = {'cron' => "* * * * *", 'class' => 'SomeRealClass', 'args' => "/tmp"}
85
+ Resque::Job.expects(:create).with(SomeRealClass.queue, SomeRealClass, '/tmp')
86
+ Resque::Scheduler.enqueue_from_config(config)
87
+ end
88
+
89
+ def test_enqueue_runs_hooks
90
+ # The job should be loaded, since a missing rails_env means ALL envs.
91
+ ENV['RAILS_ENV'] = 'production'
92
+ config = {'cron' => "* * * * *", 'class' => 'SomeRealClass', 'args' => "/tmp"}
93
+
94
+ Resque::Job.expects(:create).with(SomeRealClass.queue, SomeRealClass, '/tmp')
95
+ SomeRealClass.expects(:after_enqueue_example)
96
+
97
+ Resque::Scheduler.enqueue_from_config(config)
98
+ end
99
+
81
100
  def test_config_makes_it_into_the_rufus_scheduler
82
101
  assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
83
102
 
@@ -87,53 +106,53 @@ class Resque::SchedulerTest < Test::Unit::TestCase
87
106
  assert_equal(1, Resque::Scheduler.rufus_scheduler.all_jobs.size)
88
107
  assert Resque::Scheduler.scheduled_jobs.include?(:some_ivar_job)
89
108
  end
90
-
109
+
91
110
  def test_can_reload_schedule
92
111
  Resque::Scheduler.dynamic = true
93
112
  Resque.schedule = {"some_ivar_job" => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp"}}
94
-
113
+
95
114
  Resque::Scheduler.load_schedule!
96
115
 
97
116
  assert_equal(1, Resque::Scheduler.rufus_scheduler.all_jobs.size)
98
117
  assert Resque::Scheduler.scheduled_jobs.include?("some_ivar_job")
99
-
118
+
100
119
  Resque.redis.del(:schedules)
101
120
  Resque.redis.hset(:schedules, "some_ivar_job2", Resque.encode(
102
121
  {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/2"}
103
122
  ))
104
-
123
+
105
124
  Resque::Scheduler.reload_schedule!
106
-
125
+
107
126
  assert_equal(1, Resque::Scheduler.rufus_scheduler.all_jobs.size)
108
-
127
+
109
128
  assert_equal '/tmp/2', Resque.schedule["some_ivar_job2"]["args"]
110
129
  assert Resque::Scheduler.scheduled_jobs.include?("some_ivar_job2")
111
130
  end
112
-
131
+
113
132
  def test_load_schedule_job
114
133
  Resque::Scheduler.load_schedule_job("some_ivar_job", {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp"})
115
-
134
+
116
135
  assert_equal(1, Resque::Scheduler.rufus_scheduler.all_jobs.size)
117
136
  assert_equal(1, Resque::Scheduler.scheduled_jobs.size)
118
137
  assert Resque::Scheduler.scheduled_jobs.keys.include?("some_ivar_job")
119
138
  end
120
-
139
+
121
140
  def test_load_schedule_job_with_no_cron
122
141
  Resque::Scheduler.load_schedule_job("some_ivar_job", {'class' => 'SomeIvarJob', 'args' => "/tmp"})
123
-
142
+
124
143
  assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
125
144
  assert_equal(0, Resque::Scheduler.scheduled_jobs.size)
126
145
  assert !Resque::Scheduler.scheduled_jobs.keys.include?("some_ivar_job")
127
146
  end
128
-
147
+
129
148
  def test_load_schedule_job_with_blank_cron
130
149
  Resque::Scheduler.load_schedule_job("some_ivar_job", {'cron' => '', 'class' => 'SomeIvarJob', 'args' => "/tmp"})
131
-
150
+
132
151
  assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
133
152
  assert_equal(0, Resque::Scheduler.scheduled_jobs.size)
134
153
  assert !Resque::Scheduler.scheduled_jobs.keys.include?("some_ivar_job")
135
154
  end
136
-
155
+
137
156
  def test_update_schedule
138
157
  Resque::Scheduler.dynamic = true
139
158
  Resque.schedule = {
@@ -141,9 +160,9 @@ class Resque::SchedulerTest < Test::Unit::TestCase
141
160
  "another_ivar_job" => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/5"},
142
161
  "stay_put_job" => {'cron' => "* * * * *", 'class' => 'SomeJob', 'args' => "/tmp"}
143
162
  }
144
-
163
+
145
164
  Resque::Scheduler.load_schedule!
146
-
165
+
147
166
  Resque.set_schedule("some_ivar_job",
148
167
  {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/2"}
149
168
  )
@@ -154,9 +173,9 @@ class Resque::SchedulerTest < Test::Unit::TestCase
154
173
  {'cron' => "* * * * *", 'class' => 'SomeJob', 'args' => "/tmp"}
155
174
  )
156
175
  Resque.remove_schedule("another_ivar_job")
157
-
176
+
158
177
  Resque::Scheduler.update_schedule
159
-
178
+
160
179
  assert_equal(3, Resque::Scheduler.rufus_scheduler.all_jobs.size)
161
180
  assert_equal(3, Resque::Scheduler.scheduled_jobs.size)
162
181
  %w(some_ivar_job new_ivar_job stay_put_job).each do |job_name|
@@ -167,7 +186,7 @@ class Resque::SchedulerTest < Test::Unit::TestCase
167
186
  assert !Resque.schedule.keys.include?("another_ivar_job")
168
187
  assert_equal 0, Resque.redis.scard(:schedules_changed)
169
188
  end
170
-
189
+
171
190
  def test_update_schedule_with_mocks
172
191
  Resque::Scheduler.dynamic = true
173
192
  Resque.schedule = {
@@ -175,12 +194,12 @@ class Resque::SchedulerTest < Test::Unit::TestCase
175
194
  "another_ivar_job" => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/5"},
176
195
  "stay_put_job" => {'cron' => "* * * * *", 'class' => 'SomeJob', 'args' => "/tmp"}
177
196
  }
178
-
197
+
179
198
  Resque::Scheduler.load_schedule!
180
-
199
+
181
200
  Resque::Scheduler.rufus_scheduler.expects(:unschedule).with(Resque::Scheduler.scheduled_jobs["some_ivar_job"].job_id)
182
201
  Resque::Scheduler.rufus_scheduler.expects(:unschedule).with(Resque::Scheduler.scheduled_jobs["another_ivar_job"].job_id)
183
-
202
+
184
203
  Resque.set_schedule("some_ivar_job",
185
204
  {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/2"}
186
205
  )
@@ -191,9 +210,9 @@ class Resque::SchedulerTest < Test::Unit::TestCase
191
210
  {'cron' => "* * * * *", 'class' => 'SomeJob', 'args' => "/tmp"}
192
211
  )
193
212
  Resque.remove_schedule("another_ivar_job")
194
-
213
+
195
214
  Resque::Scheduler.update_schedule
196
-
215
+
197
216
  assert_equal(3, Resque::Scheduler.scheduled_jobs.size)
198
217
  %w(some_ivar_job new_ivar_job stay_put_job).each do |job_name|
199
218
  assert Resque::Scheduler.scheduled_jobs.keys.include?(job_name)
@@ -203,33 +222,33 @@ class Resque::SchedulerTest < Test::Unit::TestCase
203
222
  assert !Resque.schedule.keys.include?("another_ivar_job")
204
223
  assert_equal 0, Resque.redis.scard(:schedules_changed)
205
224
  end
206
-
225
+
207
226
  def test_set_schedules
208
227
  Resque::Scheduler.dynamic = true
209
228
  Resque.schedule = {"my_ivar_job" => {
210
229
  'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/75"
211
230
  }}
212
- assert_equal({'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/75"},
231
+ assert_equal({'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/75"},
213
232
  Resque.decode(Resque.redis.hget(:schedules, "my_ivar_job")))
214
233
  end
215
-
234
+
216
235
  def test_set_schedule
217
236
  Resque.set_schedule("some_ivar_job", {
218
237
  'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/22"
219
238
  })
220
- assert_equal({'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/22"},
239
+ assert_equal({'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/22"},
221
240
  Resque.decode(Resque.redis.hget(:schedules, "some_ivar_job")))
222
241
  assert Resque.redis.sismember(:schedules_changed, "some_ivar_job")
223
242
  end
224
-
243
+
225
244
  def test_get_schedule
226
245
  Resque.redis.hset(:schedules, "some_ivar_job2", Resque.encode(
227
246
  {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/33"}
228
247
  ))
229
- assert_equal({'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/33"},
248
+ assert_equal({'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/33"},
230
249
  Resque.get_schedule("some_ivar_job2"))
231
250
  end
232
-
251
+
233
252
  def test_remove_schedule
234
253
  Resque.redis.hset(:schedules, "some_ivar_job3", Resque.encode(
235
254
  {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/44"}
data/test/test_helper.rb CHANGED
@@ -59,11 +59,11 @@ def context(*args, &block)
59
59
  klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
60
60
  def self.test(name, &block)
61
61
  define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
62
- end
63
- def self.xtest(*args) end
64
- def self.setup(&block) define_method(:setup, &block) end
65
- def self.teardown(&block) define_method(:teardown, &block) end
66
- end
62
+ end
63
+ def self.xtest(*args) end
64
+ def self.setup(&block) define_method(:setup, &block) end
65
+ def self.teardown(&block) define_method(:teardown, &block) end
66
+ end
67
67
  (class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
68
68
  klass.class_eval &block
69
69
  end
@@ -76,3 +76,9 @@ end
76
76
  class SomeIvarJob < SomeJob
77
77
  @queue = :ivar
78
78
  end
79
+
80
+ class SomeRealClass
81
+ def self.queue
82
+ :some_real_queue
83
+ end
84
+ end
metadata CHANGED
@@ -1,120 +1,91 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: resque-scheduler
3
- version: !ruby/object:Gem::Version
4
- prerelease: true
5
- segments:
6
- - 2
7
- - 0
8
- - 0
9
- - d
10
- version: 2.0.0.d
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0.e
5
+ prerelease: 6
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Ben VandenBos
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-04-03 00:00:00 -07:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-09-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: bundler
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2163772500 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- segments:
30
- - 1
31
- - 0
32
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 1.0.0
34
22
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: redis
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2163772500
25
+ - !ruby/object:Gem::Dependency
26
+ name: redis
27
+ requirement: &2163770620 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- segments:
45
- - 2
46
- - 0
47
- - 1
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
48
32
  version: 2.0.1
49
33
  type: :runtime
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: resque
53
34
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2163770620
36
+ - !ruby/object:Gem::Dependency
37
+ name: resque
38
+ requirement: &2163770140 !ruby/object:Gem::Requirement
55
39
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- segments:
60
- - 1
61
- - 8
62
- - 0
63
- version: 1.8.0
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.15.0
64
44
  type: :runtime
65
- version_requirements: *id003
66
- - !ruby/object:Gem::Dependency
67
- name: rufus-scheduler
68
45
  prerelease: false
69
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *2163770140
47
+ - !ruby/object:Gem::Dependency
48
+ name: rufus-scheduler
49
+ requirement: &2163769660 !ruby/object:Gem::Requirement
70
50
  none: false
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- segments:
75
- - 0
76
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
77
55
  type: :runtime
78
- version_requirements: *id004
79
- - !ruby/object:Gem::Dependency
80
- name: mocha
81
56
  prerelease: false
82
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *2163769660
58
+ - !ruby/object:Gem::Dependency
59
+ name: mocha
60
+ requirement: &2163769160 !ruby/object:Gem::Requirement
83
61
  none: false
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- segments:
88
- - 0
89
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
90
66
  type: :development
91
- version_requirements: *id005
92
- - !ruby/object:Gem::Dependency
93
- name: rack-test
94
67
  prerelease: false
95
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *2163769160
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: &2163768680 !ruby/object:Gem::Requirement
96
72
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- segments:
101
- - 0
102
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
103
77
  type: :development
104
- version_requirements: *id006
105
- description: |-
106
- Light weight job scheduling on top of Resque.
107
- Adds methods enqueue_at/enqueue_in to schedule jobs in the future.
108
- Also supports queueing jobs on a fixed, cron-like schedule.
109
- email:
78
+ prerelease: false
79
+ version_requirements: *2163768680
80
+ description: ! "Light weight job scheduling on top of Resque.\n Adds methods enqueue_at/enqueue_in
81
+ to schedule jobs in the future.\n Also supports queueing jobs on a fixed, cron-like
82
+ schedule."
83
+ email:
110
84
  - bvandenbos@gmail.com
111
85
  executables: []
112
-
113
86
  extensions: []
114
-
115
87
  extra_rdoc_files: []
116
-
117
- files:
88
+ files:
118
89
  - .gitignore
119
90
  - Gemfile
120
91
  - Gemfile.lock
@@ -138,39 +109,31 @@ files:
138
109
  - test/scheduler_args_test.rb
139
110
  - test/scheduler_test.rb
140
111
  - test/test_helper.rb
141
- has_rdoc: true
142
112
  homepage: http://github.com/bvandenbos/resque-scheduler
143
113
  licenses: []
144
-
145
114
  post_install_message:
146
115
  rdoc_options: []
147
-
148
- require_paths:
116
+ require_paths:
149
117
  - lib
150
- required_ruby_version: !ruby/object:Gem::Requirement
118
+ required_ruby_version: !ruby/object:Gem::Requirement
151
119
  none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- segments:
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ segments:
156
125
  - 0
157
- version: "0"
158
- required_rubygems_version: !ruby/object:Gem::Requirement
126
+ hash: -3350821914372278115
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
128
  none: false
160
- requirements:
161
- - - ">="
162
- - !ruby/object:Gem::Version
163
- segments:
164
- - 1
165
- - 3
166
- - 6
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
167
132
  version: 1.3.6
168
133
  requirements: []
169
-
170
134
  rubyforge_project:
171
- rubygems_version: 1.3.7
135
+ rubygems_version: 1.8.5
172
136
  signing_key:
173
137
  specification_version: 3
174
138
  summary: Light weight job scheduling on top of Resque
175
139
  test_files: []
176
-