##// END OF EJS Templates
Fixes section edit links when text includes pre/code tag (#2222)....
Jean-Philippe Lang -
r7715:b3b2eb3e50c5
parent child
Show More
@@ -489,6 +489,7 module ApplicationHelper
489 489 text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr)
490 490
491 491 @parsed_headings = []
492 @current_section = 0 if options[:edit_section_links]
492 493 text = parse_non_pre_blocks(text) do |text|
493 494 [:parse_sections, :parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros, :parse_headings].each do |method_name|
494 495 send method_name, text, project, obj, attr, only_path, options
@@ -732,12 +733,11 module ApplicationHelper
732 733
733 734 def parse_sections(text, project, obj, attr, only_path, options)
734 735 return unless options[:edit_section_links]
735 section = 0
736 736 text.gsub!(HEADING_RE) do
737 section += 1
738 if section > 1
737 @current_section += 1
738 if @current_section > 1
739 739 content_tag('div',
740 link_to(image_tag('edit.png'), options[:edit_section_links].merge(:section => section)),
740 link_to(image_tag('edit.png'), options[:edit_section_links].merge(:section => @current_section)),
741 741 :class => 'contextual',
742 742 :title => l(:button_edit_section)) + $1
743 743 else
@@ -111,6 +111,8 wiki_contents_011:
111 111
112 112 h2. Heading 1
113 113
114 @WHATEVER@
115
114 116 Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in.
115 117
116 118 Cras ipsum felis, ultrices at porttitor vel, faucibus eu nunc.
@@ -79,6 +79,20 class WikiControllerTest < ActionController::TestCase
79 79 get :show, :project_id => 1, :id => 'Unexistent page'
80 80 assert_response 404
81 81 end
82
83 def test_show_should_display_section_edit_links
84 @request.session[:user_id] = 2
85 get :show, :project_id => 1, :id => 'Page with sections'
86 assert_no_tag 'a', :attributes => {
87 :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=1'
88 }
89 assert_tag 'a', :attributes => {
90 :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2'
91 }
92 assert_tag 'a', :attributes => {
93 :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=3'
94 }
95 end
82 96
83 97 def test_show_unexistent_page_with_edit_right
84 98 @request.session[:user_id] = 2
General Comments 0
You need to be logged in to leave comments. Login now