From c428bce1e111462f47cab5cba1d463725e830a8f Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Sun, 20 Feb 2022 15:49:42 +0000 Subject: [PATCH] Merged r21413 to 4.2-stable (#36561). git-svn-id: http://svn.redmine.org/redmine/branches/4.2-stable@21418 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/wiki_controller.rb | 2 +- app/models/wiki_page.rb | 6 +----- test/functional/wiki_controller_test.rb | 6 ++++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 045517b6c..6b2cfc0a7 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -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 diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index c3d09fd22..b0c5da3d2 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -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) diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 73b1e3658..1ebbce9f3 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -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} -- 2.39.5