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
4 changes: 4 additions & 0 deletions app/controllers/maintenance_tasks/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ class ApplicationController < MaintenanceTasks.parent_controller.constantize
end

protect_from_forgery with: :exception

rescue_from Task::NotFoundError do |error|
render("maintenance_tasks/not_found", status: :not_found)
end
end
end
9 changes: 9 additions & 0 deletions app/views/maintenance_tasks/not_found.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% content_for :page_title, "Not Found" %>

<div class="container has-text-centered">
<h1 class="title is-3 has-text-weight-bold">Task Not Found</h1>
<p class="subtitle is-5">The task you are looking for does not exist or has been deleted.</p>
<p>
<%= link_to "Back to Tasks", tasks_path, class: "button is-primary is-rounded" %>
</p>
</div>
4 changes: 0 additions & 4 deletions lib/maintenance_tasks/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,5 @@ class Engine < ::Rails::Engine
config.after_initialize do
JobIteration.max_job_runtime ||= 5.minutes
end

config.action_dispatch.rescue_responses.merge!(
"MaintenanceTasks::Task::NotFoundError" => :not_found,
)
end
end
10 changes: 10 additions & 0 deletions test/system/maintenance_tasks/tasks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ class TasksTest < ApplicationSystemTestCase
assert_button "Run", disabled: true
end

test "show a not found Task" do
visit maintenance_tasks_path + "/tasks/Maintenance::DoesNotExist"

assert_title "Not Found"
Comment thread
kaibadash marked this conversation as resolved.
assert_includes page.driver.browser.logs.get(:browser).sole.message, "404"
assert_text "Task Not Found"
assert_text "The task you are looking for does not exist or has been deleted."
assert_link "Back to Tasks"
end

test "visit main page through iframe" do
visit root_path

Expand Down
Loading