From 8158a26ee8006290338373731adbde1179a3130d Mon Sep 17 00:00:00 2001 From: Etienne Massip Date: Sun, 2 Oct 2011 15:35:39 +0000 Subject: [PATCH] Merged #7560 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@7561 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 2 +- test/unit/helpers/application_helper_test.rb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 01b96b5eb..12cee39f0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -556,7 +556,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 0608894e3..f73d67992 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>

", -- 2.39.5