Skip to content
This repository
Browse code

Use Resque.enqueue_to to set the queue (Issue #151)

  • Loading branch information...
commit 9db9e9e2512636d31d9d9f8e0a761b74f3f43408 1 parent d0369d0
Ben VandenBos authored
1  .gitignore
@@ -3,3 +3,4 @@ doc/
3 3
 pkg
4 4
 nbproject
5 5
 Gemfile.lock
  6
+.rvmrc
2  lib/resque/scheduler.rb
@@ -218,7 +218,7 @@ def enqueue_from_config(job_config)
218 218
           # one app that schedules for another
219 219
           if Class === klass
220 220
             ResqueScheduler::Plugin.run_before_delayed_enqueue_hooks(klass, *params)
221  
-            Resque.enqueue(klass, *params)
  221
+            Resque.enqueue_to(queue, klass, *params)
222 222
           else
223 223
             # This will not run the before_hooks in rescue, but will at least
224 224
             # queue the job.
2  lib/resque_scheduler.rb
@@ -111,7 +111,7 @@ def remove_schedule(name)
111 111
   # sit in the schedule list.
112 112
   def enqueue_at(timestamp, klass, *args)
113 113
     validate_job!(klass)
114  
-    enqueue_at_with_queue( queue_from_class(klass), timestamp, klass, *args)
  114
+    enqueue_at_with_queue(queue_from_class(klass), timestamp, klass, *args)
115 115
   end
116 116
 
117 117
   # Identical to +enqueue_at+, except you can also specify
2  resque-scheduler.gemspec
@@ -22,6 +22,6 @@ Gem::Specification.new do |s|
22 22
   s.require_path = 'lib'
23 23
 
24 24
   s.add_runtime_dependency(%q<redis>, [">= 2.0.1"])
25  
-  s.add_runtime_dependency(%q<resque>, [">= 1.19.0"])
  25
+  s.add_runtime_dependency(%q<resque>, [">= 1.20.0"])
26 26
   s.add_runtime_dependency(%q<rufus-scheduler>, [">= 0"])
27 27
 end
6  test/delayed_queue_test.rb
@@ -170,7 +170,7 @@
170 170
     Resque.enqueue_at(t, SomeIvarJob)
171 171
 
172 172
     # 2 SomeIvarJob jobs should be created in the "ivar" queue
173  
-    Resque::Job.expects(:create).twice.with(:ivar, SomeIvarJob, nil)
  173
+    Resque::Job.expects(:create).twice.with('ivar', SomeIvarJob, nil)
174 174
     Resque::Scheduler.handle_delayed_items
175 175
   end
176 176
 
@@ -180,7 +180,7 @@
180 180
     Resque.enqueue_at(t, SomeIvarJob)
181 181
 
182 182
     # 2 SomeIvarJob jobs should be created in the "ivar" queue
183  
-    Resque::Job.expects(:create).twice.with(:ivar, SomeIvarJob, nil)
  183
+    Resque::Job.expects(:create).twice.with('ivar', SomeIvarJob, nil)
184 184
     Resque::Scheduler.handle_delayed_items(t)
185 185
   end
186 186
 
@@ -191,7 +191,7 @@
191 191
     Resque.enqueue_at(t, SomeIvarJob)
192 192
 
193 193
     # 2 SomeIvarJob jobs should be created in the "ivar" queue
194  
-    Resque::Job.expects(:create).twice.with(:ivar, SomeIvarJob, nil)
  194
+    Resque::Job.expects(:create).twice.with('ivar', SomeIvarJob, nil)
195 195
 
196 196
     Resque::Scheduler.enqueue_delayed_items_for_timestamp(t)
197 197
 
8  test/scheduler_test.rb
@@ -32,6 +32,14 @@
32 32
     Resque::Scheduler.enqueue_from_config(config)
33 33
   end
34 34
 
  35
+  test "enqueue_from_config respects queue params" do
  36
+    config = {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'queue' => 'high'}
  37
+
  38
+    Resque.expects(:enqueue_to).with('high', SomeIvarJob)
  39
+
  40
+    Resque::Scheduler.enqueue_from_config(config)
  41
+  end
  42
+
35 43
   test "config makes it into the rufus_scheduler" do
36 44
     assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
37 45
 

0 notes on commit 9db9e9e

Please sign in to comment.
Something went wrong with that request. Please try again.