@@ -60,8 +60,6 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase | |||
|
60 | 60 | |
|
61 | 61 | def setup |
|
62 | 62 | @hook_module = Redmine::Hook |
|
63 | @hook_helper = TestHookHelperController.new | |
|
64 | @view_hook_helper = TestHookHelperView.new(RAILS_ROOT + '/app/views') | |
|
65 | 63 | end |
|
66 | 64 | |
|
67 | 65 | def teardown |
@@ -86,64 +84,64 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase | |||
|
86 | 84 | |
|
87 | 85 | def test_call_hook |
|
88 | 86 | @hook_module.add_listener(TestHook1) |
|
89 |
assert_equal ['Test hook 1 listener.'], |
|
|
87 | assert_equal ['Test hook 1 listener.'], hook_helper.call_hook(:view_layouts_base_html_head) | |
|
90 | 88 | end |
|
91 | 89 | |
|
92 | 90 | def test_call_hook_with_context |
|
93 | 91 | @hook_module.add_listener(TestHook3) |
|
94 | 92 | assert_equal ['Context keys: bar, controller, foo, project, request.'], |
|
95 |
|
|
|
93 | hook_helper.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a') | |
|
96 | 94 | end |
|
97 | 95 | |
|
98 | 96 | def test_call_hook_with_multiple_listeners |
|
99 | 97 | @hook_module.add_listener(TestHook1) |
|
100 | 98 | @hook_module.add_listener(TestHook2) |
|
101 |
assert_equal ['Test hook 1 listener.', 'Test hook 2 listener.'], |
|
|
99 | assert_equal ['Test hook 1 listener.', 'Test hook 2 listener.'], hook_helper.call_hook(:view_layouts_base_html_head) | |
|
102 | 100 | end |
|
103 | 101 | |
|
104 | 102 | # Context: Redmine::Hook::Helper.call_hook default_url |
|
105 | 103 | def test_call_hook_default_url_options |
|
106 | 104 | @hook_module.add_listener(TestLinkToHook) |
|
107 | 105 | |
|
108 |
assert_equal ['<a href="/issues">Issues</a>'], |
|
|
106 | assert_equal ['<a href="/issues">Issues</a>'], hook_helper.call_hook(:view_layouts_base_html_head) | |
|
109 | 107 | end |
|
110 | 108 | |
|
111 | 109 | # Context: Redmine::Hook::Helper.call_hook |
|
112 | 110 | def test_call_hook_with_project_added_to_context |
|
113 | 111 | @hook_module.add_listener(TestHook3) |
|
114 |
assert_match /project/i, |
|
|
112 | assert_match /project/i, hook_helper.call_hook(:view_layouts_base_html_head)[0] | |
|
115 | 113 | end |
|
116 | 114 | |
|
117 | 115 | def test_call_hook_from_controller_with_controller_added_to_context |
|
118 | 116 | @hook_module.add_listener(TestHook3) |
|
119 |
assert_match /controller/i, |
|
|
117 | assert_match /controller/i, hook_helper.call_hook(:view_layouts_base_html_head)[0] | |
|
120 | 118 | end |
|
121 | 119 | |
|
122 | 120 | def test_call_hook_from_controller_with_request_added_to_context |
|
123 | 121 | @hook_module.add_listener(TestHook3) |
|
124 |
assert_match /request/i, |
|
|
122 | assert_match /request/i, hook_helper.call_hook(:view_layouts_base_html_head)[0] | |
|
125 | 123 | end |
|
126 | 124 | |
|
127 | 125 | def test_call_hook_from_view_with_project_added_to_context |
|
128 | 126 | @hook_module.add_listener(TestHook3) |
|
129 |
assert_match /project/i, |
|
|
127 | assert_match /project/i, view_hook_helper.call_hook(:view_layouts_base_html_head) | |
|
130 | 128 | end |
|
131 | 129 | |
|
132 | 130 | def test_call_hook_from_view_with_controller_added_to_context |
|
133 | 131 | @hook_module.add_listener(TestHook3) |
|
134 |
assert_match /controller/i, |
|
|
132 | assert_match /controller/i, view_hook_helper.call_hook(:view_layouts_base_html_head) | |
|
135 | 133 | end |
|
136 | 134 | |
|
137 | 135 | def test_call_hook_from_view_with_request_added_to_context |
|
138 | 136 | @hook_module.add_listener(TestHook3) |
|
139 |
assert_match /request/i, |
|
|
137 | assert_match /request/i, view_hook_helper.call_hook(:view_layouts_base_html_head) | |
|
140 | 138 | end |
|
141 | 139 | |
|
142 | 140 | def test_call_hook_from_view_should_join_responses_with_a_space |
|
143 | 141 | @hook_module.add_listener(TestHook1) |
|
144 | 142 | @hook_module.add_listener(TestHook2) |
|
145 | 143 | assert_equal 'Test hook 1 listener. Test hook 2 listener.', |
|
146 |
|
|
|
144 | view_hook_helper.call_hook(:view_layouts_base_html_head) | |
|
147 | 145 | end |
|
148 | 146 | |
|
149 | 147 | def test_call_hook_should_not_change_the_default_url_for_email_notifications |
@@ -154,7 +152,7 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase | |||
|
154 | 152 | mail = ActionMailer::Base.deliveries.last |
|
155 | 153 | |
|
156 | 154 | @hook_module.add_listener(TestLinkToHook) |
|
157 |
|
|
|
155 | hook_helper.call_hook(:view_layouts_base_html_head) | |
|
158 | 156 | |
|
159 | 157 | ActionMailer::Base.deliveries.clear |
|
160 | 158 | Mailer.deliver_issue_add(issue) |
@@ -162,5 +160,13 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase | |||
|
162 | 160 | |
|
163 | 161 | assert_equal mail.body, mail2.body |
|
164 | 162 |
|
|
163 | ||
|
164 | def hook_helper | |
|
165 | @hook_helper ||= TestHookHelperController.new | |
|
166 | end | |
|
167 | ||
|
168 | def view_hook_helper | |
|
169 | @view_hook_helper ||= TestHookHelperView.new(RAILS_ROOT + '/log') | |
|
170 | end | |
|
165 | 171 | end |
|
166 | 172 |
General Comments 0
You need to be logged in to leave comments.
Login now