summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-11 10:02:24 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-11 10:02:24 +0000
commit686430ee3674abb8ff1c622d40fcce1926512c80 (patch)
tree926523df1b2fa12d82b12da5eb73c5834ee99dcb
parent165327a074d8fc248da3a9721f1ad9a155b72cd6 (diff)
downloadredmine-686430ee3674abb8ff1c622d40fcce1926512c80.tar.gz
redmine-686430ee3674abb8ff1c622d40fcce1926512c80.zip
Fixed: wrong section edit links when a heading contains inline code (#10199).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8841 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/application_helper.rb5
-rw-r--r--test/unit/helpers/application_helper_test.rb45
2 files changed, 49 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 78c4b7b2e..ac59ae87f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -504,11 +504,14 @@ module ApplicationHelper
@parsed_headings = []
@current_section = 0 if options[:edit_section_links]
+
+ parse_sections(text, project, obj, attr, only_path, options)
text = parse_non_pre_blocks(text) do |text|
- [:parse_sections, :parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros, :parse_headings].each do |method_name|
+ [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros].each do |method_name|
send method_name, text, project, obj, attr, only_path, options
end
end
+ parse_headings(text, project, obj, attr, only_path, options)
if @parsed_headings.any?
replace_toc(text, @parsed_headings)
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 3e00030b5..732ac2a96 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -799,6 +799,8 @@ some code
h3. Subtitle with *some* _modifiers_
+h3. Subtitle with @inline code@
+
h1. Another title
h3. An "Internet link":http://www.redmine.org/ inside subtitle
@@ -815,6 +817,7 @@ RAW
'<li><a href="#Subtitle-with-red-text">Subtitle with red text</a>' +
'<ul>' +
'<li><a href="#Subtitle-with-some-modifiers">Subtitle with some modifiers</a></li>' +
+ '<li><a href="#Subtitle-with-inline-code">Subtitle with inline code</a></li>' +
'</ul>' +
'</li>' +
'</ul>' +
@@ -853,6 +856,48 @@ RAW
assert textilizable(raw).gsub("\n", "").include?(expected)
end
+ def test_section_edit_links
+ raw = <<-RAW
+h1. Title
+
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
+
+h2. Subtitle with a [[Wiki]] link
+
+h2. Subtitle with *some* _modifiers_
+
+h2. Subtitle with @inline code@
+
+<pre>
+some code
+
+h2. heading inside pre
+
+<h2>html heading inside pre</h2>
+</pre>
+
+h2. Subtitle after pre tag
+RAW
+
+ @project = Project.find(1)
+ set_language_if_valid 'en'
+ result = textilizable(raw, :edit_section_links => {:controller => 'wiki', :action => 'edit', :project_id => '1', :id => 'Test'}).gsub("\n", "")
+
+ # heading that contains inline code
+ assert_match Regexp.new('<div class="contextual" title="Edit this section">' +
+ '<a href="/projects/1/wiki/Test/edit\?section=4"><img alt="Edit" src="/images/edit.png(\?\d+)?" /></a></div>' +
+ '<a name="Subtitle-with-inline-code"></a>' +
+ '<h2 >Subtitle with <code>inline code</code><a href="#Subtitle-with-inline-code" class="wiki-anchor">&para;</a></h2>'),
+ result
+
+ # last heading
+ assert_match Regexp.new('<div class="contextual" title="Edit this section">' +
+ '<a href="/projects/1/wiki/Test/edit\?section=5"><img alt="Edit" src="/images/edit.png(\?\d+)?" /></a></div>' +
+ '<a name="Subtitle-after-pre-tag"></a>' +
+ '<h2 >Subtitle after pre tag<a href="#Subtitle-after-pre-tag" class="wiki-anchor">&para;</a></h2>'),
+ result
+ end
+
def test_default_formatter
with_settings :text_formatting => 'unknown' do
text = 'a *link*: http://www.example.net/'