summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/wiki_controller.rb9
-rw-r--r--lib/redmine/wiki_formatting.rb5
-rw-r--r--test/unit/lib/redmine/wiki_formatting.rb10
3 files changed, 21 insertions, 3 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index ba37a511f..b247867d1 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -85,7 +85,10 @@ class WikiController < ApplicationController
end
end
@editable = editable?
- @sections_editable = @editable && User.current.allowed_to?(:edit_wiki_pages, @page.project) && params[:version].nil?
+ @sections_editable = @editable && User.current.allowed_to?(:edit_wiki_pages, @page.project) &&
+ params[:version].nil? &&
+ Redmine::WikiFormatting.supports_section_edit?
+
render :action => 'show'
end
@@ -103,7 +106,7 @@ class WikiController < ApplicationController
@content.version = @page.content.version
@text = @content.text
- if params[:section].present?
+ if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
@section = params[:section].to_i
@text, @section_hash = Redmine::WikiFormatting.formatter.new(@text).get_section(@section)
render_404 if @text.blank?
@@ -131,7 +134,7 @@ class WikiController < ApplicationController
@content.comments = params[:content][:comments]
@text = params[:content][:text]
- if params[:section].present?
+ if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
@section = params[:section].to_i
@section_hash = params[:section_hash]
@content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(params[:section].to_i, @text, @section_hash)
diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb
index 2f25fe0e6..63f833dce 100644
--- a/lib/redmine/wiki_formatting.rb
+++ b/lib/redmine/wiki_formatting.rb
@@ -62,6 +62,11 @@ module Redmine
text
end
+ # Returns true if the text formatter supports single section edit
+ def supports_section_edit?
+ (formatter.instance_methods & ['update_section', :update_section]).any?
+ end
+
# Returns a cache key for the given text +format+, +object+ and +attribute+ or nil if no caching should be done
def cache_key_for(format, object, attribute)
if object && attribute && !object.new_record? && object.respond_to?(:updated_on) && !format.blank?
diff --git a/test/unit/lib/redmine/wiki_formatting.rb b/test/unit/lib/redmine/wiki_formatting.rb
index 606642e1f..909acdea7 100644
--- a/test/unit/lib/redmine/wiki_formatting.rb
+++ b/test/unit/lib/redmine/wiki_formatting.rb
@@ -42,4 +42,14 @@ EXPECTED
assert_equal expected.gsub(%r{[\r\n\t]}, ''), Redmine::WikiFormatting::NullFormatter::Formatter.new(raw).to_html.gsub(%r{[\r\n\t]}, '')
end
+
+ def test_supports_section_edit
+ with_settings :text_formatting => 'textile' do
+ assert_equal true, Redmine::WikiFormatting.supports_section_edit?
+ end
+
+ with_settings :text_formatting => '' do
+ assert_equal false, Redmine::WikiFormatting.supports_section_edit?
+ end
+ end
end