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
This commit is contained in:
Eric Davis 2009-02-21 00:23:22 +00:00
parent b6c4b21b47
commit 00b568c194
1 changed files with 21 additions and 7 deletions

View File

@ -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