From: Etienne Massip Date: Sun, 2 Oct 2011 15:32:34 +0000 (+0000) Subject: Fix generation of blank local link when no title is specified in wiki link. X-Git-Tag: 1.3.0~417 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ac2dbde135f7a63c4d57c6a7d0d07fff53f0d3ee;p=redmine.git Fix generation of blank local link when no title is specified in wiki link. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7560 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index dce6913a3..4f3316224 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -576,7 +576,7 @@ module ApplicationHelper "##{anchor}" else case options[:wiki_links] - when :local; "#{title}.html" + when :local; "#{page.present? ? Wiki.titleize(page) : ''}.html" + (anchor.present? ? "##{anchor}" : '') when :anchor; "##{title}" # used for single-file wiki export else wiki_page_id = page.present? ? Wiki.titleize(page) : nil diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index e3e788da2..366a167ea 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -375,6 +375,26 @@ RAW to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } end + def test_wiki_links_within_local_file_generation_context + + to_test = { + # link to a page + '[[CookBook documentation]]' => 'CookBook documentation', + '[[CookBook documentation|documentation]]' => 'documentation', + '[[CookBook documentation#One-section]]' => 'CookBook documentation', + '[[CookBook documentation#One-section|documentation]]' => 'documentation', + # page that doesn't exist + '[[Unknown page]]' => 'Unknown page', + '[[Unknown page|404]]' => '404', + '[[Unknown page#anchor]]' => 'Unknown page', + '[[Unknown page#anchor|404]]' => '404', + } + + @project = Project.find(1) + + to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text, :wiki_links => :local) } + end + def test_html_tags to_test = { "
content
" => "

<div>content</div>

",