Use the base layout for all 403, 404, and 500 pages. #6172
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3949 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
c090d115e2
commit
73ba49a715
|
@ -258,7 +258,7 @@ class ApplicationController < ActionController::Base
|
||||||
def render_403
|
def render_403
|
||||||
@project = nil
|
@project = nil
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :template => "common/403", :layout => (request.xhr? ? false : 'base'), :status => 403 }
|
format.html { render :template => "common/403", :layout => use_layout, :status => 403 }
|
||||||
format.atom { head 403 }
|
format.atom { head 403 }
|
||||||
format.xml { head 403 }
|
format.xml { head 403 }
|
||||||
format.js { head 403 }
|
format.js { head 403 }
|
||||||
|
@ -269,7 +269,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def render_404
|
def render_404
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :template => "common/404", :layout => !request.xhr?, :status => 404 }
|
format.html { render :template => "common/404", :layout => use_layout, :status => 404 }
|
||||||
format.atom { head 404 }
|
format.atom { head 404 }
|
||||||
format.xml { head 404 }
|
format.xml { head 404 }
|
||||||
format.js { head 404 }
|
format.js { head 404 }
|
||||||
|
@ -282,7 +282,7 @@ class ApplicationController < ActionController::Base
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
flash.now[:error] = msg
|
flash.now[:error] = msg
|
||||||
render :text => '', :layout => !request.xhr?, :status => 500
|
render :text => '', :layout => use_layout, :status => 500
|
||||||
}
|
}
|
||||||
format.atom { head 500 }
|
format.atom { head 500 }
|
||||||
format.xml { head 500 }
|
format.xml { head 500 }
|
||||||
|
@ -291,6 +291,13 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Picks which layout to use based on the request
|
||||||
|
#
|
||||||
|
# @return [boolean, string] name of the layout to use or false for no layout
|
||||||
|
def use_layout
|
||||||
|
request.xhr? ? false : 'base'
|
||||||
|
end
|
||||||
|
|
||||||
def invalid_authenticity_token
|
def invalid_authenticity_token
|
||||||
if api_request?
|
if api_request?
|
||||||
logger.error "Form authenticity token is missing or is invalid. API calls must include a proper Content-type header (text/xml or text/json)."
|
logger.error "Form authenticity token is missing or is invalid. API calls must include a proper Content-type header (text/xml or text/json)."
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
require "#{File.dirname(__FILE__)}/../test_helper"
|
||||||
|
|
||||||
|
class LayoutTest < ActionController::IntegrationTest
|
||||||
|
fixtures :all
|
||||||
|
|
||||||
|
test "browsing to a missing page should render the base layout" do
|
||||||
|
get "/users/100000000"
|
||||||
|
|
||||||
|
assert_response :not_found
|
||||||
|
|
||||||
|
# UsersController uses the admin layout by default
|
||||||
|
assert_select "#admin-menu", :count => 0
|
||||||
|
end
|
||||||
|
|
||||||
|
test "browsing to an unauthorized page should render the base layout" do
|
||||||
|
user = User.find(9)
|
||||||
|
user.password, user.password_confirmation = 'test', 'test'
|
||||||
|
user.save!
|
||||||
|
|
||||||
|
log_user('miscuser9','test')
|
||||||
|
|
||||||
|
get "/admin"
|
||||||
|
assert_response :forbidden
|
||||||
|
assert_select "#admin-menu", :count => 0
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue