Skip to content

Commit b640fee

Browse files
brunoarueirarosa
authored andcommitted
Handle blocked_until nil on the blocked jobs list
Fixes #259
1 parent 1cfb47f commit b640fee

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

app/views/mission_control/jobs/jobs/blocked/_job.html.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<td><%= link_to job.queue_name, application_queue_path(@application, job.queue) %></td>
2-
<td><div class="is-family-monospace is-size-7"><%= job.blocked_by %></div>
3-
<div class="has-text-grey is-size-7">Expires <%= bidirectional_time_distance_in_words_with_title(job.blocked_until) %></div>
2+
<td>
3+
<div class="is-family-monospace is-size-7"><%= job.blocked_by %></div>
4+
<div class="has-text-grey is-size-7"><%= job.blocked_until ? "Expires #{bidirectional_time_distance_in_words_with_title(job.blocked_until)}" : "" %></div>
45
</td>
56
<td class="pr-0">
67
<%= render "mission_control/jobs/jobs/blocked/actions", job: job %>

test/system/blocked_jobs_test.rb

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
require_relative "../application_system_test_case"
2+
3+
class BlockedJobsTest < ApplicationSystemTestCase
4+
setup do
5+
# Find a SolidQueue server to use for this test
6+
@solid_queue_server = MissionControl::Jobs.applications.first.servers.find { |s| s.queue_adapter_name == :solid_queue }
7+
8+
# Skip if SolidQueue is not available
9+
skip "SolidQueue adapter not available for testing" unless @solid_queue_server
10+
11+
# Use the SolidQueue server's activating method to switch adapters temporarily
12+
@solid_queue_server.activating do
13+
# Create jobs with SolidQueue adapter
14+
BlockingJob.perform_later(10)
15+
BlockingJob.perform_later(20)
16+
17+
# Get the last job
18+
job = ActiveJob.jobs.blocked.last
19+
20+
# Make sure the job has nil blocked_until
21+
if job.respond_to?(:blocked_execution) && job.blocked_execution
22+
job.blocked_execution.update!(expires_at: nil)
23+
end
24+
end
25+
26+
# Visit the blocked jobs page with SolidQueue active
27+
@solid_queue_server.activating do
28+
visit jobs_path(:blocked)
29+
end
30+
end
31+
32+
test "displays blocked jobs with expiration date" do
33+
@solid_queue_server.activating do
34+
assert_text "10"
35+
assert_text "Expires"
36+
end
37+
end
38+
39+
test "displays blocked jobs without expiration date" do
40+
@solid_queue_server.activating do
41+
assert_text "20"
42+
43+
within_job_row "20" do
44+
# The expiration message should be empty when blocked_until is nil
45+
assert page.has_selector?(".has-text-grey.is-size-7", text: "")
46+
end
47+
end
48+
end
49+
50+
test "run now button works for blocked jobs" do
51+
@solid_queue_server.activating do
52+
assert_equal 2, job_row_elements.length
53+
54+
within_job_row "10" do
55+
click_on "Run now"
56+
end
57+
58+
assert_text "Dispatched"
59+
assert_equal 1, job_row_elements.length
60+
end
61+
end
62+
end

0 commit comments

Comments
 (0)