Also check if the specified page is there, and return 404 if not

This commit is contained in:
Alexey Verkhovsky 2005-08-11 05:36:11 +00:00
parent fe868135c4
commit 0f35016069
2 changed files with 10 additions and 3 deletions

View file

@ -297,9 +297,11 @@ class WikiController < ApplicationController
end
def get_page_and_revision
@revision = @page.revisions[@params['rev'].to_i]
if @revision.nil?
render_text 'Page name is not specified', '404 Not Found'
revision_index = (@params['rev'] || 0).to_i
if @page.nil? or @page.revisions[revision_index].nil?
render_text 'Page not found', '404 Not Found'
else
@revision = @page.revisions[revision_index]
end
end

View file

@ -375,6 +375,11 @@ class WikiControllerTest < Test::Unit::TestCase
r = process 'revision', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '5'
assert_response :missing
end
def test_revision_of_nonexistant_page
r = process 'revision', 'web' => 'wiki1', 'id' => 'NonExistantPage', 'rev' => '0'
assert_response :missing
end
def test_rollback