]> source.dussan.org Git - redmine.git/commitdiff
Merged r21413 to 4.2-stable (#36561).
authorMarius Balteanu <marius.balteanu@zitec.com>
Sun, 20 Feb 2022 15:49:42 +0000 (15:49 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Sun, 20 Feb 2022 15:49:42 +0000 (15:49 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/4.2-stable@21418 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 045517b6cc0571d923ef2bb0142e444ba1d1e542..6b2cfc0a7283516d5865de6ba9bcf83ea9ac053d 100644 (file)
@@ -89,7 +89,7 @@ class WikiController < ApplicationController
     end
     @content = @page.content_for_version(params[:version])
     if @content.nil?
-      if User.current.allowed_to?(:edit_wiki_pages, @project) && editable? && !api_request?
+      if params[:version].blank? && User.current.allowed_to?(:edit_wiki_pages, @project) && editable? && !api_request?
         edit
         render :action => 'edit'
       else
index c3d09fd220903d72ec1f83a544f939367e098937..b0c5da3d28bc1de2913db473b1ab1b2556edc9cb 100644 (file)
@@ -162,11 +162,7 @@ class WikiPage < ActiveRecord::Base
   end
 
   def content_for_version(version=nil)
-    if content
-      result = content.versions.find_by_version(version.to_i) if version
-      result ||= content
-      result
-    end
+    (content && version) ? content.versions.find_by_version(version.to_i) : content
   end
 
   def diff(version_to=nil, version_from=nil)
index 73b1e3658a5bc75793a3c2de88d1c0290eefa8ad..1ebbce9f37a8e68c6b38c5ca4e4ef1392fe8bea7 100644 (file)
@@ -168,6 +168,12 @@ class WikiControllerTest < Redmine::ControllerTest
     assert_select 'select[name=?] option[value="2"][selected=selected]', 'wiki_page[parent_id]'
   end
 
+  def test_show_unexistent_version_page
+    @request.session[:user_id] = 2
+    get :show, :params => {:project_id => 1, :id => 'CookBook_documentation', :version => 100}
+    assert_response 404
+  end
+
   def test_show_should_not_show_history_without_permission
     Role.anonymous.remove_permission! :view_wiki_edits
     get :show, :params => {:project_id => 1, :id => 'Page with sections', :version => 2}