Skip to content

Commit d843c9f

Browse files
Josiassejod1rosa
authored andcommitted
handle finding job
1 parent b640fee commit d843c9f

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

app/controllers/mission_control/jobs/queues_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def show
1111

1212
private
1313
def set_queue
14-
@queue = ActiveJob.queues[params[:id]]
14+
@queue = ActiveJob.queues[params[:id]] || ActiveJob.queues.find { |q| q.id == params[:id] }
1515
end
1616
end

test/active_job/queue_test.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
require "test_helper"
2+
3+
class ActiveJob::QueueTest < ActiveSupport::TestCase
4+
test "to_param returns parameterized queue name" do
5+
queue = ActiveJob::Queue.new("MixedCaseQueue")
6+
assert_equal "mixedcasequeue", queue.to_param
7+
end
8+
9+
test "to_param handles queue names with special characters" do
10+
queue = ActiveJob::Queue.new("My-Queue_With.Special@Chars!")
11+
assert_equal "my-queue_with-special-chars", queue.to_param
12+
end
13+
14+
test "to_param handles queue names with spaces" do
15+
queue = ActiveJob::Queue.new("My Queue With Spaces")
16+
assert_equal "my-queue-with-spaces", queue.to_param
17+
end
18+
19+
test "to_param handles queue names with underscores" do
20+
queue = ActiveJob::Queue.new("my_queue_with_underscores")
21+
assert_equal "my_queue_with_underscores", queue.to_param
22+
end
23+
24+
test "to_param handles queue names with numbers" do
25+
queue = ActiveJob::Queue.new("Queue123With456Numbers")
26+
assert_equal "queue123with456numbers", queue.to_param
27+
end
28+
29+
test "id is an alias for to_param" do
30+
queue = ActiveJob::Queue.new("MixedCaseQueue")
31+
assert_equal queue.to_param, queue.id
32+
end
33+
34+
test "queue lookup by id works correctly" do
35+
# Create a queue with a mixed case name
36+
queue = ActiveJob::Queue.new("MixedCaseQueue")
37+
queues = ActiveJob::Queues.new([queue])
38+
39+
# Should find the queue by its parameterized id
40+
assert_equal queue, queues.find { |q| q.id == "mixedcasequeue" }
41+
42+
# Should find the queue by its original name
43+
assert_equal queue, queues["MixedCaseQueue"]
44+
end
45+
end

0 commit comments

Comments
 (0)