]> source.dussan.org Git - redmine.git/commitdiff
Fix generation of blank local link when no title is specified in wiki link.
authorEtienne Massip <etienne.massip@gmail.com>
Sun, 2 Oct 2011 15:32:34 +0000 (15:32 +0000)
committerEtienne Massip <etienne.massip@gmail.com>
Sun, 2 Oct 2011 15:32:34 +0000 (15:32 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7560 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/unit/helpers/application_helper_test.rb

index dce6913a331699a4ad399580bacf68755ddd9c9b..4f331622403d4fa5710f581339a2d9bd921cef2d 100644 (file)
@@ -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
index e3e788da2ecf3f257633a6cdb57c19eec489ec45..366a167eae03d4163c9860216ed127a3f043a907 100644 (file)
@@ -375,6 +375,26 @@ RAW
     to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
   end
 
+  def test_wiki_links_within_local_file_generation_context
+
+    to_test = {
+      # link to a page
+      '[[CookBook documentation]]' => '<a href="CookBook_documentation.html" class="wiki-page">CookBook documentation</a>',
+      '[[CookBook documentation|documentation]]' => '<a href="CookBook_documentation.html" class="wiki-page">documentation</a>',
+      '[[CookBook documentation#One-section]]' => '<a href="CookBook_documentation.html#One-section" class="wiki-page">CookBook documentation</a>',
+      '[[CookBook documentation#One-section|documentation]]' => '<a href="CookBook_documentation.html#One-section" class="wiki-page">documentation</a>',
+      # page that doesn't exist
+      '[[Unknown page]]' => '<a href="Unknown_page.html" class="wiki-page new">Unknown page</a>',
+      '[[Unknown page|404]]' => '<a href="Unknown_page.html" class="wiki-page new">404</a>',
+      '[[Unknown page#anchor]]' => '<a href="Unknown_page.html#anchor" class="wiki-page new">Unknown page</a>',
+      '[[Unknown page#anchor|404]]' => '<a href="Unknown_page.html#anchor" class="wiki-page new">404</a>',
+    }
+
+    @project = Project.find(1)
+
+    to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :wiki_links => :local) }
+  end
+
   def test_html_tags
     to_test = {
       "<div>content</div>" => "<p>&lt;div&gt;content&lt;/div&gt;</p>",