Skip to content

Using the default priority queue rather than creating an invalid one #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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