From 00b568c194db8fe1e1979795dfe548148647f431 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Sat, 21 Feb 2009 00:23:22 +0000 Subject: [PATCH] Implementing the missing tests now that HookTest has a cleaner setup. Controller and Views are now tested through the Redmine::Hook::Helper module. #2542 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2490 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/unit/lib/redmine/hook_test.rb | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/test/unit/lib/redmine/hook_test.rb b/test/unit/lib/redmine/hook_test.rb index 0411a5e0..5ebe1e75 100644 --- a/test/unit/lib/redmine/hook_test.rb +++ b/test/unit/lib/redmine/hook_test.rb @@ -50,11 +50,16 @@ class Redmine::Hook::ManagerTest < Test::Unit::TestCase include Redmine::Hook::Helper end + class TestHookHelperView < ActionView::Base + include Redmine::Hook::Helper + end + Redmine::Hook.clear_listeners def setup @hook_module = Redmine::Hook @hook_helper = TestHookHelperController.new + @view_hook_helper = TestHookHelperView.new(RAILS_ROOT + '/app/views') end def teardown @@ -134,31 +139,40 @@ class Redmine::Hook::ManagerTest < Test::Unit::TestCase # Context: Redmine::Hook::Helper.call_hook def test_call_hook_with_project_added_to_context - # TODO: Implement test + @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 - # TODO: Implement test + @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 - # TODO: Implement test + @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 - # TODO: Implement test + @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 - # TODO: Implement test + @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 - # TODO: Implement test + @hook_module.add_listener(TestHook3) + assert_match /request/i, @view_hook_helper.call_hook(:view_layouts_base_html_head) end def test_call_hook_from_view_should_join_responses_with_a_space - # TODO: Implement test + @hook_module.add_listener(TestHook1) + @hook_module.add_listener(TestHook2) + assert_equal 'Test hook 1 listener. Test hook 2 listener.', + @view_hook_helper.call_hook(:view_layouts_base_html_head) end end