redirect_to_last_remembered raises an error when it fails to redirect to home - instead of trying retrying endlessly
This commit is contained in:
parent
4053380fd4
commit
c2b9b48536
2 changed files with 14 additions and 4 deletions
|
@ -88,7 +88,11 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def redirect_home(web = @web_name)
|
||||
redirect_to_page('HomePage', web)
|
||||
if web
|
||||
redirect_to_page('HomePage', web)
|
||||
else
|
||||
redirect_to_url '/'
|
||||
end
|
||||
end
|
||||
|
||||
def redirect_to_page(page_name = @page_name, web = @web_name)
|
||||
|
@ -120,10 +124,16 @@ class ApplicationController < ActionController::Base
|
|||
def return_to_last_remembered
|
||||
# Forget the redirect location
|
||||
redirect_target, @session[:return_to] = @session[:return_to], nil
|
||||
tried_home, @session[:tried_home] = @session[:tried_home], false
|
||||
|
||||
# then try to redirect to it
|
||||
if redirect_target.nil?
|
||||
logger.debug("Session ##{session.object_id}: no remembered redirect location, trying /")
|
||||
redirect_to_url '/'
|
||||
if tried_home
|
||||
raise 'Application could not render the index page'
|
||||
else
|
||||
logger.debug("Session ##{session.object_id}: no remembered redirect location, trying home")
|
||||
redirect_home
|
||||
end
|
||||
else
|
||||
logger.debug("Session ##{session.object_id}: " +
|
||||
"redirect to the last remembered URL #{redirect_target}")
|
||||
|
|
|
@ -104,7 +104,7 @@ class FileControllerTest < Test::Unit::TestCase
|
|||
# User uploads the picture
|
||||
file = "abcdefgh\n123"
|
||||
r = process 'file', 'web' => 'wiki1', 'id' => 'instiki-e2e.txt', 'file' => StringIO.new(file)
|
||||
assert_redirect_url '/'
|
||||
assert_redirected_to :controller => 'wiki', :action => 'show', :web => 'wiki1', :id => 'HomePage'
|
||||
assert @wiki.file_yard(@web).has_file?('instiki-e2e.txt')
|
||||
assert_equal(file, File.read("#{RAILS_ROOT}/storage/test/wiki1/instiki-e2e.txt"))
|
||||
|
||||
|
|
Loading…
Reference in a new issue