summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2009-02-21 00:23:28 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2009-02-21 00:23:28 +0000
commit9a986ac0a51fe844eee816325e6a6d4122136d9a (patch)
treeae6e1de2aaa6adb2fc6952c47bf2fb79a644cb7d
parent00b568c194db8fe1e1979795dfe548148647f431 (diff)
downloadredmine-9a986ac0a51fe844eee816325e6a6d4122136d9a.tar.gz
redmine-9a986ac0a51fe844eee816325e6a6d4122136d9a.zip
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: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2491 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--lib/redmine/hook.rb11
-rw-r--r--test/unit/lib/redmine/hook_test.rb36
2 files changed, 4 insertions, 43 deletions
diff --git a/lib/redmine/hook.rb b/lib/redmine/hook.rb
index bcd23b64f..63d7a5961 100644
--- a/lib/redmine/hook.rb
+++ b/lib/redmine/hook.rb
@@ -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
diff --git a/test/unit/lib/redmine/hook_test.rb b/test/unit/lib/redmine/hook_test.rb
index 5ebe1e757..3e70c1c69 100644
--- a/test/unit/lib/redmine/hook_test.rb
+++ b/test/unit/lib/redmine/hook_test.rb
@@ -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