diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index dce6913a331699a4ad399580bacf68755ddd9c9b..4f331622403d4fa5710f581339a2d9bd921cef2d 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 e3e788da2ecf3f257633a6cdb57c19eec489ec45..366a167eae03d4163c9860216ed127a3f043a907 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>

",