GitLab ist wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht erreichbar.

Commit 7b67b3fd authored by edavis10's avatar edavis10

Refactored the mess known as Hook default_url_options in favor of the simpler

:only_path as suggested by splatteal on GitHub.

  #2542

git-svn-id: https://svn.redmine.org/redmine/trunk@2491 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent a151bc8b
......@@ -60,16 +60,7 @@ module Redmine
returning [] do |response|
hls = hook_listeners(hook)
if hls.any?
request = context[:request]
if request
default_url_options[:host] ||= request.env["SERVER_NAME"]
# Only set port if it's requested and isn't port 80. Otherwise a url
# like: +http://example.com:/url+ may be generated
if request.env["SERVER_PORT"] && request.env["SERVER_PORT"] != 80
default_url_options[:port] ||= request.env["SERVER_PORT"]
end
default_url_options[:protocol] ||= request.protocol
end
default_url_options[:only_path] ||= true
hls.each {|listener| response << listener.send(hook, context)}
end
end
......
......@@ -100,41 +100,11 @@ class Redmine::Hook::ManagerTest < Test::Unit::TestCase
assert_equal ['Test hook 1 listener.', 'Test hook 2 listener.'], @hook_helper.call_hook(:view_layouts_base_html_head)
end
# Context: Redmine::Hook::call_hook
def test_call_hook_default_url_options_set
request = ActionController::TestRequest.new
request.env = { "SERVER_NAME" => 'example.com'}
# Context: Redmine::Hook::Helper.call_hook default_url
def test_call_hook_default_url_options
@hook_module.add_listener(TestLinkToHook)
assert_equal ['<a href="http://example.com/issues">Issues</a>'],
@hook_helper.call_hook(:view_layouts_base_html_head, :request => request)
end
def test_call_hook_default_url_options_set_with_no_standard_request_port
request = ActionController::TestRequest.new
request.env = { "SERVER_NAME" => 'example.com', "SERVER_PORT" => 3000}
@hook_module.add_listener(TestLinkToHook)
assert_equal ['<a href="http://example.com:3000/issues">Issues</a>'],
@hook_helper.call_hook(:view_layouts_base_html_head, :request => request)
end
def test_call_hook_default_url_options_set_with_ssl
request = ActionController::TestRequest.new
request.env = { "SERVER_NAME" => 'example.com', "HTTPS" => 'on'}
@hook_module.add_listener(TestLinkToHook)
assert_equal ['<a href="https://example.com/issues">Issues</a>'],
@hook_helper.call_hook(:view_layouts_base_html_head, :request => request)
end
def test_call_hook_default_url_options_set_with_forwarded_ssl
request = ActionController::TestRequest.new
request.env = { "SERVER_NAME" => 'example.com', "HTTP_X_FORWARDED_PROTO" => "https"}
@hook_module.add_listener(TestLinkToHook)
assert_equal ['<a href="https://example.com/issues">Issues</a>'],
@hook_helper.call_hook(:view_layouts_base_html_head, :request => request)
assert_equal ['<a href="/issues">Issues</a>'], @hook_helper.call_hook(:view_layouts_base_html_head)
end
# Context: Redmine::Hook::Helper.call_hook
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment