Mercurial > hg > soundsoftware-site
comparison test/unit/lib/redmine/hook_test.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | cbb26bc654de |
children | 622f24f53b42 261b3d9a4903 |
comparison
equal
deleted
inserted
replaced
929:5f33065ddc4b | 1115:433d4f72a19b |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2011 Jean-Philippe Lang | 2 # Copyright (C) 2006-2012 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require File.expand_path('../../../../test_helper', __FILE__) | 18 require File.expand_path('../../../../test_helper', __FILE__) |
19 | 19 |
20 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase | 20 class Redmine::Hook::ManagerTest < ActionView::TestCase |
21 | 21 fixtures :projects, :users, :members, :member_roles, :roles, |
22 fixtures :issues | 22 :groups_users, |
23 :trackers, :projects_trackers, | |
24 :enabled_modules, | |
25 :versions, | |
26 :issue_statuses, :issue_categories, :issue_relations, :workflows, | |
27 :enumerations, | |
28 :issues | |
23 | 29 |
24 # Some hooks that are manually registered in these tests | 30 # Some hooks that are manually registered in these tests |
25 class TestHook < Redmine::Hook::ViewListener; end | 31 class TestHook < Redmine::Hook::ViewListener; end |
26 | 32 |
27 class TestHook1 < TestHook | 33 class TestHook1 < TestHook |
87 assert_equal ['Test hook 1 listener.'], hook_helper.call_hook(:view_layouts_base_html_head) | 93 assert_equal ['Test hook 1 listener.'], hook_helper.call_hook(:view_layouts_base_html_head) |
88 end | 94 end |
89 | 95 |
90 def test_call_hook_with_context | 96 def test_call_hook_with_context |
91 @hook_module.add_listener(TestHook3) | 97 @hook_module.add_listener(TestHook3) |
92 assert_equal ['Context keys: bar, controller, foo, project, request.'], | 98 assert_equal ['Context keys: bar, controller, foo, hook_caller, project, request.'], |
93 hook_helper.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a') | 99 hook_helper.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a') |
94 end | 100 end |
95 | 101 |
96 def test_call_hook_with_multiple_listeners | 102 def test_call_hook_with_multiple_listeners |
97 @hook_module.add_listener(TestHook1) | 103 @hook_module.add_listener(TestHook1) |
146 | 152 |
147 def test_call_hook_should_not_change_the_default_url_for_email_notifications | 153 def test_call_hook_should_not_change_the_default_url_for_email_notifications |
148 issue = Issue.find(1) | 154 issue = Issue.find(1) |
149 | 155 |
150 ActionMailer::Base.deliveries.clear | 156 ActionMailer::Base.deliveries.clear |
151 Mailer.deliver_issue_add(issue) | 157 Mailer.issue_add(issue).deliver |
152 mail = ActionMailer::Base.deliveries.last | 158 mail = ActionMailer::Base.deliveries.last |
153 | 159 |
154 @hook_module.add_listener(TestLinkToHook) | 160 @hook_module.add_listener(TestLinkToHook) |
155 hook_helper.call_hook(:view_layouts_base_html_head) | 161 hook_helper.call_hook(:view_layouts_base_html_head) |
156 | 162 |
157 ActionMailer::Base.deliveries.clear | 163 ActionMailer::Base.deliveries.clear |
158 Mailer.deliver_issue_add(issue) | 164 Mailer.issue_add(issue).deliver |
159 mail2 = ActionMailer::Base.deliveries.last | 165 mail2 = ActionMailer::Base.deliveries.last |
160 | 166 |
161 assert_equal mail.body, mail2.body | 167 assert_equal mail_body(mail), mail_body(mail2) |
162 end | 168 end |
163 | 169 |
164 def hook_helper | 170 def hook_helper |
165 @hook_helper ||= TestHookHelperController.new | 171 @hook_helper ||= TestHookHelperController.new |
166 end | 172 end |