@@ -39,6 +39,7 class ApplicationController < ActionController::Base | |||||
39 |
|
39 | |||
40 | rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token |
|
40 | rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token | |
41 | rescue_from ::Unauthorized, :with => :deny_access |
|
41 | rescue_from ::Unauthorized, :with => :deny_access | |
|
42 | rescue_from ::ActionView::MissingTemplate, :with => :missing_template | |||
42 |
|
43 | |||
43 | include Redmine::Search::Controller |
|
44 | include Redmine::Search::Controller | |
44 | include Redmine::MenuManager::MenuController |
|
45 | include Redmine::MenuManager::MenuController | |
@@ -352,13 +353,17 class ApplicationController < ActionController::Base | |||||
352 | format.html { |
|
353 | format.html { | |
353 | render :template => 'common/error', :layout => use_layout, :status => @status |
|
354 | render :template => 'common/error', :layout => use_layout, :status => @status | |
354 | } |
|
355 | } | |
355 |
format.a |
|
356 | format.any { head @status } | |
356 | format.xml { head @status } |
|
|||
357 | format.js { head @status } |
|
|||
358 | format.json { head @status } |
|
|||
359 | end |
|
357 | end | |
360 | end |
|
358 | end | |
361 |
|
359 | |||
|
360 | # Handler for ActionView::MissingTemplate exception | |||
|
361 | def missing_template | |||
|
362 | logger.warn "Missing template, responding with 404" | |||
|
363 | @project = nil | |||
|
364 | render_404 | |||
|
365 | end | |||
|
366 | ||||
362 | # Filter for actions that provide an API response |
|
367 | # Filter for actions that provide an API response | |
363 | # but have no HTML representation for non admin users |
|
368 | # but have no HTML representation for non admin users | |
364 | def require_admin_or_api_request |
|
369 | def require_admin_or_api_request |
@@ -60,4 +60,9 class ApplicationTest < ActionController::IntegrationTest | |||||
60 | assert_response 200 |
|
60 | assert_response 200 | |
61 | assert_nil session[:user_id] |
|
61 | assert_nil session[:user_id] | |
62 | end |
|
62 | end | |
|
63 | ||||
|
64 | def test_missing_template_should_respond_with_404 | |||
|
65 | get '/login.png' | |||
|
66 | assert_response 404 | |||
|
67 | end | |||
63 | end |
|
68 | end |
General Comments 0
You need to be logged in to leave comments.
Login now