Skip to content

Handle blocked_until nil on the blocked jobs list #260

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

Merged
merged 1 commit into from
Jul 11, 2025
Merged
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
5 changes: 3 additions & 2 deletions app/views/mission_control/jobs/jobs/blocked/_job.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<td><%= link_to job.queue_name, application_queue_path(@application, job.queue) %></td>
<td><div class="is-family-monospace is-size-7"><%= job.blocked_by %></div>
<div class="has-text-grey is-size-7">Expires <%= bidirectional_time_distance_in_words_with_title(job.blocked_until) %></div>
<td>
<div class="is-family-monospace is-size-7"><%= job.blocked_by %></div>
<div class="has-text-grey is-size-7"><%= job.blocked_until ? "Expires #{bidirectional_time_distance_in_words_with_title(job.blocked_until)}" : "" %></div>
</td>
<td class="pr-0">
<%= render "mission_control/jobs/jobs/blocked/actions", job: job %>
Expand Down
62 changes: 62 additions & 0 deletions test/system/blocked_jobs_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
require_relative "../application_system_test_case"

class BlockedJobsTest < ApplicationSystemTestCase
setup do
# Find a SolidQueue server to use for this test
@solid_queue_server = MissionControl::Jobs.applications.first.servers.find { |s| s.queue_adapter_name == :solid_queue }

# Skip if SolidQueue is not available
skip "SolidQueue adapter not available for testing" unless @solid_queue_server

# Use the SolidQueue server's activating method to switch adapters temporarily
@solid_queue_server.activating do
# Create jobs with SolidQueue adapter
BlockingJob.perform_later(10)
BlockingJob.perform_later(20)

# Get the last job
job = ActiveJob.jobs.blocked.last

# Make sure the job has nil blocked_until
if job.respond_to?(:blocked_execution) && job.blocked_execution
job.blocked_execution.update!(expires_at: nil)
end
end

# Visit the blocked jobs page with SolidQueue active
@solid_queue_server.activating do
visit jobs_path(:blocked)
end
end

test "displays blocked jobs with expiration date" do
@solid_queue_server.activating do
assert_text "10"
assert_text "Expires"
end
end

test "displays blocked jobs without expiration date" do
@solid_queue_server.activating do
assert_text "20"

within_job_row "20" do
# The expiration message should be empty when blocked_until is nil
assert page.has_selector?(".has-text-grey.is-size-7", text: "")
end
end
end

test "run now button works for blocked jobs" do
@solid_queue_server.activating do
assert_equal 2, job_row_elements.length

within_job_row "10" do
click_on "Run now"
end

assert_text "Dispatched"
assert_equal 1, job_row_elements.length
end
end
end