Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sidekiq/priority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def self.priorities=(priorities)
end

def self.queue_with_priority(queue, priority)
priority.nil? ? queue : "#{queue}_#{priority}"
priority && self.priorities.include?(priority) ? "#{queue}_#{priority}" : queue
end
end
end
Expand Down
21 changes: 21 additions & 0 deletions spec/sidekiq/worker_ext_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,26 @@ def perform(first, second)
'queue' => 'foo_high'
}
end

it 'sends an item to the default queue if priority is nil' do
TestWorker.stub(:client_push) { |item| item }
item = TestWorker.perform_with_priority(:invalid_priority, 1, 2)
item.should == {
'class' => TestWorker,
'args' => [1, 2],
'queue' => :foo
}
end

it 'sends an item to the default queue if a random priority is given' do
TestWorker.stub(:client_push) { |item| item }
item = TestWorker.perform_with_priority(:random_priority, 1, 2)
item.should == {
'class' => TestWorker,
'args' => [1, 2],
'queue' => :foo
}
end

end
end