Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

The send_* options now insert in to the default configured queue if o…

…ne is configured.
  • Loading branch information...
commit 42a983ab57a3912d7cbf8df61a5b9943906702a7 1 parent 95ca6d5
@bracken bracken authored
Showing with 29 additions and 2 deletions.
  1. +1 −1  lib/delayed/backend/base.rb
  2. +28 −1 spec/delayed_method_spec.rb
View
2  lib/delayed/backend/base.rb
@@ -23,7 +23,7 @@ def enqueue(*args)
options = args.first || {}
options[:priority] ||= 0
options[:payload_object] = object
-
+ options[:queue] ||= Delayed::Worker.queue
self.create(options)
end
end
View
29 spec/delayed_method_spec.rb
@@ -1,7 +1,10 @@
require 'spec_helper'
describe 'random ruby objects' do
- before { Delayed::Job.delete_all }
+ before :each do
+ Delayed::Worker.queue = nil
+ Delayed::Job.delete_all
+ end
it "should respond_to :send_later method" do
Object.new.respond_to?(:send_later)
@@ -56,6 +59,19 @@
job.payload_object.args.should == [1, 5]
job.payload_object.perform.should == 'Once upon...'
end
+
+ context "send_later" do
+ it "should use the default queue if there is one" do
+ Delayed::Worker.queue = "testqueue"
+ job = "string".send_later :reverse
+ job.queue.should == "testqueue"
+ end
+
+ it "should have nil queue if there is not a default" do
+ job = "string".send_later :reverse
+ job.queue.should == nil
+ end
+ end
context "send_at" do
it "should queue a new job" do
@@ -77,6 +93,17 @@
job.payload_object.args.should == ['r']
job.payload_object.perform.should == 1
end
+
+ it "should use the default queue if there is one" do
+ Delayed::Worker.queue = "testqueue"
+ job = "string".send_at 1.hour.from_now, :reverse
+ job.queue.should == "testqueue"
+ end
+
+ it "should have nil queue if there is not a default" do
+ job = "string".send_at 1.hour.from_now, :reverse
+ job.queue.should == nil
+ end
end
context "send_at_with_queue" do
Please sign in to comment.
Something went wrong with that request. Please try again.