From bbc0f07b74e239630276618e79ac03a0959c7586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Wed, 30 Dec 2015 14:27:16 +0100 Subject: [PATCH] returns 404 for not found pages (instead of 500 by MissingTemplate) Fixes #792 --- app/controllers/pages_controller.rb | 2 ++ spec/controllers/pages_controller_spec.rb | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index c00bcf95b..34cdb2e09 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -3,5 +3,7 @@ class PagesController < ApplicationController def show render action: params[:id] + rescue ActionView::MissingTemplate + raise ActionController::RoutingError.new('Not Found') end end diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index d0d04fc69..b696adb77 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -58,4 +58,10 @@ describe PagesController do end end + describe 'Not found pages' do + it 'should return a 404 message' do + expect { get :show, id: "nonExistentPage" }.to raise_error(ActionController::RoutingError) + end + end + end