diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index dfc5ba20..c5200d58 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -65,6 +65,9 @@ class ApplicationController < ActionController::Base filter_parameter_logging :password rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token + # FIXME: This doesn't work with Rails >= 3.0 anymore + # Possible workaround: https://github.com/rails/rails/issues/671#issuecomment-1780159 + rescue_from ActionController::RoutingError, :with => proc{render_404} include Redmine::Search::Controller include Redmine::MenuManager::MenuController diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 321bc42f..7503437c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -436,8 +436,8 @@ module ApplicationHelper css << 'theme-' + theme.name end - css << 'controller-' + params[:controller] - css << 'action-' + params[:action] + css << 'controller-' + params[:controller] if params[:controller] + css << 'action-' + params[:action] if params[:action] css.join(' ') end diff --git a/test/integration/application_test.rb b/test/integration/application_test.rb index d99bf190..e4366af5 100644 --- a/test/integration/application_test.rb +++ b/test/integration/application_test.rb @@ -49,4 +49,13 @@ class ApplicationTest < ActionController::IntegrationTest assert_response 200 assert_nil session[:user_id] end + + def test_always_use_custom_404 + get 'something_not_existing' + assert_response :not_found + + assert_tag :tag => 'p', + :attributes => {:id => 'errorExplanation'}, + :content => "The page you were trying to access doesn't exist or has been removed." + end end