summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-11-28 18:11:30 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-11-28 18:11:30 +0000
commit63dc83fc0d57dff4e908639d7843b0b1dc220f12 (patch)
tree989e8e32435149515b7325ad7b691a3d3a0b0ea0
parent9f15517095c4877ce5ae798210b8f5204a157ec9 (diff)
downloadredmine-63dc83fc0d57dff4e908639d7843b0b1dc220f12.tar.gz
redmine-63dc83fc0d57dff4e908639d7843b0b1dc220f12.zip
Fixed: Section-edit buttons not available when a the version parameter is provided even if it's the current version (#9674).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7970 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/wiki_controller.rb2
-rw-r--r--test/fixtures/wiki_content_versions.yml22
-rw-r--r--test/functional/wiki_controller_test.rb18
3 files changed, 41 insertions, 1 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index b247867d1..8713e91c4 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -86,7 +86,7 @@ class WikiController < ApplicationController
end
@editable = editable?
@sections_editable = @editable && User.current.allowed_to?(:edit_wiki_pages, @page.project) &&
- params[:version].nil? &&
+ @content.version == @page.content.version &&
Redmine::WikiFormatting.supports_section_edit?
render :action => 'show'
diff --git a/test/fixtures/wiki_content_versions.yml b/test/fixtures/wiki_content_versions.yml
index 652f0fb39..cdfeadd94 100644
--- a/test/fixtures/wiki_content_versions.yml
+++ b/test/fixtures/wiki_content_versions.yml
@@ -53,4 +53,26 @@ wiki_content_versions_004:
version: 1
author_id: 1
comments:
+wiki_content_versions_005:
+ data: |-
+ h1. Title
+
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
+
+ h2. Heading 1
+
+ @WHATEVER@
+
+ Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in.
+
+ h2. Heading 2
+
+ Morbi facilisis accumsan orci non pharetra.
+ updated_on: 2007-03-08 00:16:07 +01:00
+ page_id: 11
+ wiki_content_id: 11
+ id: 5
+ version: 2
+ author_id: 1
+ comments:
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index 8d2187b47..e5b4bed71 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -94,6 +94,24 @@ class WikiControllerTest < ActionController::TestCase
}
end
+ def test_show_current_version_should_display_section_edit_links
+ @request.session[:user_id] = 2
+ get :show, :project_id => 1, :id => 'Page with sections', :version => 3
+
+ assert_tag 'a', :attributes => {
+ :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2'
+ }
+ end
+
+ def test_show_old_version_should_not_display_section_edit_links
+ @request.session[:user_id] = 2
+ get :show, :project_id => 1, :id => 'Page with sections', :version => 2
+
+ assert_no_tag 'a', :attributes => {
+ :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2'
+ }
+ end
+
def test_show_unexistent_page_with_edit_right
@request.session[:user_id] = 2
get :show, :project_id => 1, :id => 'Unexistent page'