From 583be064c858b8238ac8e4d77d1d29df1ee6c3c3 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Fri, 17 Jun 2011 04:59:07 +0000 Subject: [PATCH] back out r6089. NoMethodError: undefined method `load!' for # git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6090 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/unit/lib/redmine/hook_test.rb | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/test/unit/lib/redmine/hook_test.rb b/test/unit/lib/redmine/hook_test.rb index 1a8dce3b2..27e4e2e98 100644 --- a/test/unit/lib/redmine/hook_test.rb +++ b/test/unit/lib/redmine/hook_test.rb @@ -23,7 +23,7 @@ class Redmine::Hook::ManagerTest < ActiveSupport::TestCase # Some hooks that are manually registered in these tests class TestHook < Redmine::Hook::ViewListener; end - + class TestHook1 < TestHook def view_layouts_base_html_head(context) 'Test hook 1 listener.' @@ -51,54 +51,54 @@ class Redmine::Hook::ManagerTest < ActiveSupport::TestCase class TestHookHelperController < ActionController::Base include Redmine::Hook::Helper end - + class TestHookHelperView < ActionView::Base include Redmine::Hook::Helper end - + Redmine::Hook.clear_listeners - + def setup @hook_module = Redmine::Hook end - + def teardown @hook_module.clear_listeners end - + def test_clear_listeners assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size @hook_module.add_listener(TestHook1) @hook_module.add_listener(TestHook2) assert_equal 2, @hook_module.hook_listeners(:view_layouts_base_html_head).size - + @hook_module.clear_listeners assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size end - + def test_add_listener assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size @hook_module.add_listener(TestHook1) assert_equal 1, @hook_module.hook_listeners(:view_layouts_base_html_head).size end - + def test_call_hook @hook_module.add_listener(TestHook1) assert_equal ['Test hook 1 listener.'], hook_helper.call_hook(:view_layouts_base_html_head) end - + def test_call_hook_with_context @hook_module.add_listener(TestHook3) assert_equal ['Context keys: bar, controller, foo, project, request.'], hook_helper.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a') end - + def test_call_hook_with_multiple_listeners @hook_module.add_listener(TestHook1) @hook_module.add_listener(TestHook2) assert_equal ['Test hook 1 listener.', 'Test hook 2 listener.'], hook_helper.call_hook(:view_layouts_base_html_head) end - + # Context: Redmine::Hook::Helper.call_hook default_url def test_call_hook_default_url_options @hook_module.add_listener(TestLinkToHook) @@ -111,27 +111,27 @@ class Redmine::Hook::ManagerTest < ActiveSupport::TestCase @hook_module.add_listener(TestHook3) assert_match /project/i, hook_helper.call_hook(:view_layouts_base_html_head)[0] end - + def test_call_hook_from_controller_with_controller_added_to_context @hook_module.add_listener(TestHook3) assert_match /controller/i, hook_helper.call_hook(:view_layouts_base_html_head)[0] end - + def test_call_hook_from_controller_with_request_added_to_context @hook_module.add_listener(TestHook3) assert_match /request/i, hook_helper.call_hook(:view_layouts_base_html_head)[0] end - + def test_call_hook_from_view_with_project_added_to_context @hook_module.add_listener(TestHook3) assert_match /project/i, view_hook_helper.call_hook(:view_layouts_base_html_head) end - + def test_call_hook_from_view_with_controller_added_to_context @hook_module.add_listener(TestHook3) assert_match /controller/i, view_hook_helper.call_hook(:view_layouts_base_html_head) end - + def test_call_hook_from_view_with_request_added_to_context @hook_module.add_listener(TestHook3) assert_match /request/i, view_hook_helper.call_hook(:view_layouts_base_html_head) @@ -146,27 +146,27 @@ class Redmine::Hook::ManagerTest < ActiveSupport::TestCase def test_call_hook_should_not_change_the_default_url_for_email_notifications issue = Issue.find(1) - + ActionMailer::Base.deliveries.clear Mailer.deliver_issue_add(issue) mail = ActionMailer::Base.deliveries.last - + @hook_module.add_listener(TestLinkToHook) hook_helper.call_hook(:view_layouts_base_html_head) - + ActionMailer::Base.deliveries.clear Mailer.deliver_issue_add(issue) mail2 = ActionMailer::Base.deliveries.last - + assert_equal mail.body, mail2.body end - + def hook_helper @hook_helper ||= TestHookHelperController.new end def view_hook_helper - @view_hook_helper ||= TestHookHelperView.new(Rails.root + '/app/views') + @view_hook_helper ||= TestHookHelperView.new(RAILS_ROOT + '/app/views') end end