]> source.dussan.org Git - redmine.git/commitdiff
link_to in Redmine::Hook::ViewListener omits relative url root (#19024).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 7 Feb 2015 07:32:25 +0000 (07:32 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 7 Feb 2015 07:32:25 +0000 (07:32 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13960 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/hook.rb
test/unit/lib/redmine/hook_test.rb

index bc8dc7e1c89030e6cc7430b14456e0d1cdc52df9..7f518d8d4ab8b16bdec0be108cc8b4e59164eb5a 100644 (file)
@@ -96,7 +96,7 @@ module Redmine
       # Default to creating links using only the path.  Subclasses can
       # change this default as needed
       def self.default_url_options
-        {:only_path => true }
+        {:only_path => true, :script_name => Redmine::Utils.relative_url_root}
       end
 
       # Helper method to directly render using the context,
index 5093abaa603d6cd5f7e8716cf823be7ea7f580a1..109abc888e207f6c978259a9bb3c06b26e46aa9e 100644 (file)
@@ -114,6 +114,15 @@ class Redmine::Hook::ManagerTest < ActionView::TestCase
     assert_equal ['<a href="/issues">Issues</a>'], hook_helper.call_hook(:view_layouts_base_html_head)
   end
 
+  def test_view_hook_should_generate_links_with_relative_url_root
+    Redmine::Utils.relative_url_root = '/foo'
+    @hook_module.add_listener(TestLinkToHook)
+
+    assert_equal ['<a href="/foo/issues">Issues</a>'], hook_helper.call_hook(:view_layouts_base_html_head)
+  ensure
+    Redmine::Utils.relative_url_root = ''
+  end
+
   # Context: Redmine::Hook::Helper.call_hook
   def test_call_hook_with_project_added_to_context
     @hook_module.add_listener(TestHook3)