From f6ee7cb06832fd2059480d2fc6fe32721aa70383 Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Thu, 9 Mar 2017 15:18:21 -0500 Subject: [PATCH] Wrap 404s in site template --- app/controllers/catch_all_controller.rb | 5 +++++ app/views/catch_all/catch_all.html.erb | 3 +++ config/routes.rb | 2 ++ test/integration/catch_all_test.rb | 8 ++++++++ 4 files changed, 18 insertions(+) create mode 100644 app/controllers/catch_all_controller.rb create mode 100644 app/views/catch_all/catch_all.html.erb create mode 100644 test/integration/catch_all_test.rb diff --git a/app/controllers/catch_all_controller.rb b/app/controllers/catch_all_controller.rb new file mode 100644 index 00000000..0073b107 --- /dev/null +++ b/app/controllers/catch_all_controller.rb @@ -0,0 +1,5 @@ +class CatchAllController < ApplicationController + def catch_all + render status: 404 + end +end diff --git a/app/views/catch_all/catch_all.html.erb b/app/views/catch_all/catch_all.html.erb new file mode 100644 index 00000000..f4ba7694 --- /dev/null +++ b/app/views/catch_all/catch_all.html.erb @@ -0,0 +1,3 @@ +

Ooops! The requested page was not found.

+ +

<%= link_to('Starting over', root_path) %> may help. If it does not, please <%= link_to('let us know', feedback_path) %>!

diff --git a/config/routes.rb b/config/routes.rb index 423be70e..68c6a5d9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,4 +22,6 @@ get 'item_status', to: 'aleph#item_status' get 'debug', to: 'application#debug' + + get '*path', to: 'catch_all#catch_all' end diff --git a/test/integration/catch_all_test.rb b/test/integration/catch_all_test.rb new file mode 100644 index 00000000..28cb7963 --- /dev/null +++ b/test/integration/catch_all_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class CatchAllTest < ActionDispatch::IntegrationTest + test 'handle 404s' do + get '/blargh' + assert_response :not_found + end +end