diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 18de3aa2..bf5492dd 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -205,11 +205,11 @@ class WikiController < ApplicationController return end - page_name = @page_name || 'HomePage' - page = wiki.read_page(@web_name, page_name) - render(:text => "Page '#{page_name}' not found", :status => 404) and return unless page + @page_name ||= 'HomePage' + @page ||= wiki.read_page(@web_name, @page_name) + render(:text => "Page '#{@page_name}' not found", :status => 404) and return unless @page - @renderer = PageRenderer.new(page.revisions.last) + @renderer = PageRenderer.new(@page.revisions.last) end def revision diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index cbb11d0b..3edf75b4 100755 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -293,6 +293,15 @@ class WikiControllerTest < Test::Unit::TestCase assert_response :missing end + def test_published_should_render_homepage_if_no_page_specified + set_web_property :published, true + + r = process('published', 'web' => 'wiki1') + + assert_success + assert_equal @home, r.template_objects['page'] + end + def test_recently_revised r = process('recently_revised', 'web' => 'wiki1')