summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-11-11 07:22:21 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-11-11 07:22:21 +0000
commit40ba35f6c228fa12a4b409c1c81723969554a7ad (patch)
tree984b8603ea2efb6065280dcfd904389f88abf14e
parent1c97ce41ffacb490426e8fb9608850949b437145 (diff)
downloadredmine-40ba35f6c228fa12a4b409c1c81723969554a7ad.tar.gz
redmine-40ba35f6c228fa12a4b409c1c81723969554a7ad.zip
Merged r14856 (#21155).
git-svn-id: http://svn.redmine.org/redmine/branches/3.1-stable@14860 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/wiki_controller.rb9
-rw-r--r--test/functional/wiki_controller_test.rb12
2 files changed, 18 insertions, 3 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 6f6c6bbdf..eabfe1c46 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -266,9 +266,12 @@ class WikiController < ApplicationController
def destroy_version
return render_403 unless editable?
- @content = @page.content_for_version(params[:version])
- @content.destroy
- redirect_to_referer_or history_project_wiki_page_path(@project, @page.title)
+ if content = @page.content.versions.find_by_version(params[:version])
+ content.destroy
+ redirect_to_referer_or history_project_wiki_page_path(@project, @page.title)
+ else
+ render_404
+ end
end
# Export wiki to a single pdf or html file
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index 9bffe66c7..e3e960f53 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -756,6 +756,18 @@ class WikiControllerTest < ActionController::TestCase
end
end
+ def test_destroy_invalid_version_should_respond_with_404
+ @request.session[:user_id] = 2
+ assert_no_difference 'WikiContent::Version.count' do
+ assert_no_difference 'WikiContent.count' do
+ assert_no_difference 'WikiPage.count' do
+ delete :destroy_version, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => 99
+ end
+ end
+ end
+ assert_response 404
+ end
+
def test_index
get :index, :project_id => 'ecookbook'
assert_response :success