Skip to content

Commit

Permalink
Use Resque.enqueue_to to set the queue (Issue resque#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvandenbos committed Apr 10, 2012
1 parent d0369d0 commit 9db9e9e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@ doc/
pkg
nbproject
Gemfile.lock
.rvmrc
2 changes: 1 addition & 1 deletion lib/resque/scheduler.rb
Expand Up @@ -218,7 +218,7 @@ def enqueue_from_config(job_config)
# one app that schedules for another
if Class === klass
ResqueScheduler::Plugin.run_before_delayed_enqueue_hooks(klass, *params)
Resque.enqueue(klass, *params)
Resque.enqueue_to(queue, klass, *params)
else
# This will not run the before_hooks in rescue, but will at least
# queue the job.
Expand Down
2 changes: 1 addition & 1 deletion lib/resque_scheduler.rb
Expand Up @@ -111,7 +111,7 @@ def remove_schedule(name)
# sit in the schedule list.
def enqueue_at(timestamp, klass, *args)
validate_job!(klass)
enqueue_at_with_queue( queue_from_class(klass), timestamp, klass, *args)
enqueue_at_with_queue(queue_from_class(klass), timestamp, klass, *args)
end

# Identical to +enqueue_at+, except you can also specify
Expand Down
2 changes: 1 addition & 1 deletion resque-scheduler.gemspec
Expand Up @@ -22,6 +22,6 @@ Gem::Specification.new do |s|
s.require_path = 'lib'

s.add_runtime_dependency(%q<redis>, [">= 2.0.1"])
s.add_runtime_dependency(%q<resque>, [">= 1.19.0"])
s.add_runtime_dependency(%q<resque>, [">= 1.20.0"])
s.add_runtime_dependency(%q<rufus-scheduler>, [">= 0"])
end
6 changes: 3 additions & 3 deletions test/delayed_queue_test.rb
Expand Up @@ -170,7 +170,7 @@
Resque.enqueue_at(t, SomeIvarJob)

# 2 SomeIvarJob jobs should be created in the "ivar" queue
Resque::Job.expects(:create).twice.with(:ivar, SomeIvarJob, nil)
Resque::Job.expects(:create).twice.with('ivar', SomeIvarJob, nil)
Resque::Scheduler.handle_delayed_items
end

Expand All @@ -180,7 +180,7 @@
Resque.enqueue_at(t, SomeIvarJob)

# 2 SomeIvarJob jobs should be created in the "ivar" queue
Resque::Job.expects(:create).twice.with(:ivar, SomeIvarJob, nil)
Resque::Job.expects(:create).twice.with('ivar', SomeIvarJob, nil)
Resque::Scheduler.handle_delayed_items(t)
end

Expand All @@ -191,7 +191,7 @@
Resque.enqueue_at(t, SomeIvarJob)

# 2 SomeIvarJob jobs should be created in the "ivar" queue
Resque::Job.expects(:create).twice.with(:ivar, SomeIvarJob, nil)
Resque::Job.expects(:create).twice.with('ivar', SomeIvarJob, nil)

Resque::Scheduler.enqueue_delayed_items_for_timestamp(t)

Expand Down
8 changes: 8 additions & 0 deletions test/scheduler_test.rb
Expand Up @@ -32,6 +32,14 @@
Resque::Scheduler.enqueue_from_config(config)
end

test "enqueue_from_config respects queue params" do
config = {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'queue' => 'high'}

Resque.expects(:enqueue_to).with('high', SomeIvarJob)

Resque::Scheduler.enqueue_from_config(config)
end

test "config makes it into the rufus_scheduler" do
assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)

Expand Down

0 comments on commit 9db9e9e

Please sign in to comment.