]> source.dussan.org Git - redmine.git/commitdiff
Fixed that requesting a specific version of a non-existent wiki page raises an error...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 15 Mar 2014 11:41:24 +0000 (11:41 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 15 Mar 2014 11:41:24 +0000 (11:41 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12971 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/wiki_page.rb
test/functional/wiki_controller_test.rb

index ba418118f2d3a9f0172fa32fb3ba3024693a4631..fc56d9d6b4d76a6b9043ea5d286c46a02a4f0f69 100644 (file)
@@ -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)
index 79ccb1c774e141fc8613fa7b27ebae24cc3dfd7b..3e25be08e2d70105c03be6a95e5881e497eeea14 100644 (file)
@@ -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'