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
|
@ -88,7 +88,11 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_home(web = @web_name)
|
def redirect_home(web = @web_name)
|
||||||
|
if web
|
||||||
redirect_to_page('HomePage', web)
|
redirect_to_page('HomePage', web)
|
||||||
|
else
|
||||||
|
redirect_to_url '/'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_to_page(page_name = @page_name, web = @web_name)
|
def redirect_to_page(page_name = @page_name, web = @web_name)
|
||||||
|
@ -120,10 +124,16 @@ class ApplicationController < ActionController::Base
|
||||||
def return_to_last_remembered
|
def return_to_last_remembered
|
||||||
# Forget the redirect location
|
# Forget the redirect location
|
||||||
redirect_target, @session[:return_to] = @session[:return_to], nil
|
redirect_target, @session[:return_to] = @session[:return_to], nil
|
||||||
|
tried_home, @session[:tried_home] = @session[:tried_home], false
|
||||||
|
|
||||||
# then try to redirect to it
|
# then try to redirect to it
|
||||||
if redirect_target.nil?
|
if redirect_target.nil?
|
||||||
logger.debug("Session ##{session.object_id}: no remembered redirect location, trying /")
|
if tried_home
|
||||||
redirect_to_url '/'
|
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
|
else
|
||||||
logger.debug("Session ##{session.object_id}: " +
|
logger.debug("Session ##{session.object_id}: " +
|
||||||
"redirect to the last remembered URL #{redirect_target}")
|
"redirect to the last remembered URL #{redirect_target}")
|
||||||
|
|
|
@ -104,7 +104,7 @@ class FileControllerTest < Test::Unit::TestCase
|
||||||
# User uploads the picture
|
# User uploads the picture
|
||||||
file = "abcdefgh\n123"
|
file = "abcdefgh\n123"
|
||||||
r = process 'file', 'web' => 'wiki1', 'id' => 'instiki-e2e.txt', 'file' => StringIO.new(file)
|
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 @wiki.file_yard(@web).has_file?('instiki-e2e.txt')
|
||||||
assert_equal(file, File.read("#{RAILS_ROOT}/storage/test/wiki1/instiki-e2e.txt"))
|
assert_equal(file, File.read("#{RAILS_ROOT}/storage/test/wiki1/instiki-e2e.txt"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue