]> source.dussan.org Git - redmine.git/commitdiff
Merged r11258 from trunk (#12930).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 12 Feb 2013 17:56:39 +0000 (17:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 12 Feb 2013 17:56:39 +0000 (17:56 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.2-stable@11361 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 41fc2a44f4cd328b13d122f4fde583ee95e9f3c5..f6797dc472c0a49d65e548b5456adafb1793cecf 100644 (file)
@@ -704,10 +704,11 @@ module ApplicationHelper
   #     identifier:document:"Some document"
   #     identifier:version:1.0.0
   #     identifier:source:some/file
-  def parse_redmine_links(text, project, obj, attr, only_path, options)
+  def parse_redmine_links(text, default_project, obj, attr, only_path, options)
     text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
       leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $2, $3, $4, $5, $10, $11, $8 || $12 || $18, $14 || $19, $15, $17
       link = nil
+      project = default_project
       if project_identifier
         project = Project.visible.find_by_identifier(project_identifier)
       end
index b68e4b39b421f8918b272238cb5ca4c499ec907d..e62abb6b76bb00ac45a138003e30f220ac1c5cb3 100644 (file)
@@ -347,6 +347,15 @@ RAW
     to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" }
   end
 
+  def test_redmine_links_with_a_different_project_before_current_project
+    vp1 = Version.generate!(:project_id => 1, :name => '1.4.4')
+    vp3 = Version.generate!(:project_id => 3, :name => '1.4.4')
+
+    @project = Project.find(3)
+    assert_equal %(<p><a href="/versions/#{vp1.id}" class="version">1.4.4</a> <a href="/versions/#{vp3.id}" class="version">1.4.4</a></p>),
+      textilizable("ecookbook:version:1.4.4 version:1.4.4")
+  end
+
   def test_escaped_redmine_links_should_not_be_parsed
     to_test = [
       '#3.',