From 0cb303f09fe3d2f63c478147ccaa24360c9732dd Mon Sep 17 00:00:00 2001 From: "Watal M. Iwasaki" Date: Thu, 2 Apr 2020 18:07:33 +0900 Subject: [PATCH] Check page.nil? before page.wiki (#1535) --- lib/gollum/app.rb | 2 +- test/test_app.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index ba9bbcc2..058dfbe4 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -413,8 +413,8 @@ module Precious @page = wikip.page @page_num = [params[:page_num].to_i, 1].max @max_count = settings.wiki_options.fetch(:pagination_count, 10) - @wiki = @page.wiki unless @page.nil? + @wiki = @page.wiki @versions = @page.versions( per_page: @max_count, page_num: @page_num, diff --git a/test/test_app.rb b/test/test_app.rb index 0d4c2556..c18efa9f 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -647,6 +647,14 @@ EOF assert_match /meta name="robots" content="noindex, nofollow"/, last_response.body end + test 'history/NO-EXIST redirects to Home' do + get '/gollum/history/NO-EXIST' + follow_redirect! + assert_equal last_request.fullpath, '/' + # redirect again from / to /Home + assert_equal last_response.status, 302 + end + def app Precious::App end