From c61a6a707f21db4901e8ac1232f1fd99cfed5653 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 17 Mar 2014 08:30:30 +0000 Subject: [PATCH] Merged r12971 (#16255). git-svn-id: http://svn.redmine.org/redmine/branches/2.5-stable@12979 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/wiki_page.rb | 8 +++++--- test/functional/wiki_controller_test.rb | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index ba418118f..fc56d9d6b 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -104,9 +104,11 @@ class WikiPage < ActiveRecord::Base end def content_for_version(version=nil) - result = content.versions.find_by_version(version.to_i) if version - result ||= content - result + if content + result = content.versions.find_by_version(version.to_i) if version + result ||= content + result + end end def diff(version_to=nil, version_from=nil) diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 79ccb1c77..3e25be08e 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -161,6 +161,11 @@ class WikiControllerTest < ActionController::TestCase assert_template 'edit' end + def test_show_specific_version_of_an_unexistent_page_without_edit_right + get :show, :project_id => 1, :id => 'Unexistent page', :version => 1 + assert_response 404 + end + def test_show_unexistent_page_with_parent_should_preselect_parent @request.session[:user_id] = 2 get :show, :project_id => 1, :id => 'Unexistent page', :parent => 'Another_page'