@@ -46,10 +46,15 class Redmine::Hook::ManagerTest < Test::Unit::TestCase | |||||
46 | end |
|
46 | end | |
47 | end |
|
47 | end | |
48 |
|
48 | |||
|
49 | class TestHookHelperController < ActionController::Base | |||
|
50 | include Redmine::Hook::Helper | |||
|
51 | end | |||
|
52 | ||||
49 | Redmine::Hook.clear_listeners |
|
53 | Redmine::Hook.clear_listeners | |
50 |
|
54 | |||
51 | def setup |
|
55 | def setup | |
52 | @hook_module = Redmine::Hook |
|
56 | @hook_module = Redmine::Hook | |
|
57 | @hook_helper = TestHookHelperController.new | |||
53 | end |
|
58 | end | |
54 |
|
59 | |||
55 | def teardown |
|
60 | def teardown | |
@@ -75,18 +80,19 class Redmine::Hook::ManagerTest < Test::Unit::TestCase | |||||
75 |
|
80 | |||
76 | def test_call_hook |
|
81 | def test_call_hook | |
77 | @hook_module.add_listener(TestHook1) |
|
82 | @hook_module.add_listener(TestHook1) | |
78 |
assert_equal ['Test hook 1 listener.'], @hook_ |
|
83 | assert_equal ['Test hook 1 listener.'], @hook_helper.call_hook(:view_layouts_base_html_head) | |
79 | end |
|
84 | end | |
80 |
|
85 | |||
81 | def test_call_hook_with_context |
|
86 | def test_call_hook_with_context | |
82 | @hook_module.add_listener(TestHook3) |
|
87 | @hook_module.add_listener(TestHook3) | |
83 | assert_equal ['Context keys: bar, foo.'], @hook_module.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a') |
|
88 | assert_equal ['Context keys: bar, controller, foo, project, request.'], | |
|
89 | @hook_helper.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a') | |||
84 | end |
|
90 | end | |
85 |
|
91 | |||
86 | def test_call_hook_with_multiple_listeners |
|
92 | def test_call_hook_with_multiple_listeners | |
87 | @hook_module.add_listener(TestHook1) |
|
93 | @hook_module.add_listener(TestHook1) | |
88 | @hook_module.add_listener(TestHook2) |
|
94 | @hook_module.add_listener(TestHook2) | |
89 |
assert_equal ['Test hook 1 listener.', 'Test hook 2 listener.'], @hook_ |
|
95 | assert_equal ['Test hook 1 listener.', 'Test hook 2 listener.'], @hook_helper.call_hook(:view_layouts_base_html_head) | |
90 | end |
|
96 | end | |
91 |
|
97 | |||
92 | # Context: Redmine::Hook::call_hook |
|
98 | # Context: Redmine::Hook::call_hook | |
@@ -96,7 +102,7 class Redmine::Hook::ManagerTest < Test::Unit::TestCase | |||||
96 | @hook_module.add_listener(TestLinkToHook) |
|
102 | @hook_module.add_listener(TestLinkToHook) | |
97 |
|
103 | |||
98 | assert_equal ['<a href="http://example.com/issues">Issues</a>'], |
|
104 | assert_equal ['<a href="http://example.com/issues">Issues</a>'], | |
99 |
@hook_ |
|
105 | @hook_helper.call_hook(:view_layouts_base_html_head, :request => request) | |
100 | end |
|
106 | end | |
101 |
|
107 | |||
102 | def test_call_hook_default_url_options_set_with_no_standard_request_port |
|
108 | def test_call_hook_default_url_options_set_with_no_standard_request_port | |
@@ -105,7 +111,7 class Redmine::Hook::ManagerTest < Test::Unit::TestCase | |||||
105 | @hook_module.add_listener(TestLinkToHook) |
|
111 | @hook_module.add_listener(TestLinkToHook) | |
106 |
|
112 | |||
107 | assert_equal ['<a href="http://example.com:3000/issues">Issues</a>'], |
|
113 | assert_equal ['<a href="http://example.com:3000/issues">Issues</a>'], | |
108 |
@hook_ |
|
114 | @hook_helper.call_hook(:view_layouts_base_html_head, :request => request) | |
109 | end |
|
115 | end | |
110 |
|
116 | |||
111 | def test_call_hook_default_url_options_set_with_ssl |
|
117 | def test_call_hook_default_url_options_set_with_ssl | |
@@ -114,7 +120,7 class Redmine::Hook::ManagerTest < Test::Unit::TestCase | |||||
114 | @hook_module.add_listener(TestLinkToHook) |
|
120 | @hook_module.add_listener(TestLinkToHook) | |
115 |
|
121 | |||
116 | assert_equal ['<a href="https://example.com/issues">Issues</a>'], |
|
122 | assert_equal ['<a href="https://example.com/issues">Issues</a>'], | |
117 |
@hook_ |
|
123 | @hook_helper.call_hook(:view_layouts_base_html_head, :request => request) | |
118 | end |
|
124 | end | |
119 |
|
125 | |||
120 | def test_call_hook_default_url_options_set_with_forwarded_ssl |
|
126 | def test_call_hook_default_url_options_set_with_forwarded_ssl | |
@@ -123,7 +129,7 class Redmine::Hook::ManagerTest < Test::Unit::TestCase | |||||
123 | @hook_module.add_listener(TestLinkToHook) |
|
129 | @hook_module.add_listener(TestLinkToHook) | |
124 |
|
130 | |||
125 | assert_equal ['<a href="https://example.com/issues">Issues</a>'], |
|
131 | assert_equal ['<a href="https://example.com/issues">Issues</a>'], | |
126 |
@hook_ |
|
132 | @hook_helper.call_hook(:view_layouts_base_html_head, :request => request) | |
127 | end |
|
133 | end | |
128 |
|
134 | |||
129 | # Context: Redmine::Hook::Helper.call_hook |
|
135 | # Context: Redmine::Hook::Helper.call_hook |
General Comments 0
You need to be logged in to leave comments.
Login now