@@ -1,30 +1,73 | |||
|
1 | 1 | require File.dirname(__FILE__) + '/../../../test_helper' |
|
2 | 2 | |
|
3 | 3 | class Redmine::Plugin::Hook::ManagerTest < Test::Unit::TestCase |
|
4 | def setup | |
|
5 | @manager = Redmine::Plugin::Hook::Manager | |
|
6 | end | |
|
7 | ||
|
8 | def teardown | |
|
9 | @manager.clear_listeners | |
|
10 | end | |
|
11 | ||
|
4 | 12 | def test_sanity |
|
5 | 13 | assert true |
|
6 | 14 | end |
|
15 | ||
|
16 | def test_hook_format | |
|
17 | assert_kind_of Hash, @manager::hooks | |
|
18 | @manager::hooks.each do |hook, registrations| | |
|
19 | assert_kind_of Symbol, hook | |
|
20 | assert_kind_of Array, registrations | |
|
21 | assert_equal 0, registrations.length | |
|
22 | end | |
|
23 | end | |
|
24 | ||
|
25 | def test_valid_hook | |
|
26 | assert @manager::valid_hook?(:issue_show) | |
|
27 | end | |
|
28 | ||
|
29 | def test_invalid_hook | |
|
30 | assert_equal false, @manager::valid_hook?(:an_invalid_hook_name) | |
|
31 | end | |
|
32 | ||
|
33 | def test_clear_listeners | |
|
34 | assert_equal 0, @manager::hooks[:issue_show].length | |
|
35 | @manager.add_listener(:issue_show, Proc.new { } ) | |
|
36 | @manager.add_listener(:issue_show, Proc.new { } ) | |
|
37 | @manager.add_listener(:issue_show, Proc.new { } ) | |
|
38 | @manager.add_listener(:issue_show, Proc.new { } ) | |
|
39 | assert_equal 4, @manager::hooks[:issue_show].length | |
|
40 | ||
|
41 | @manager.clear_listeners | |
|
42 | assert_equal 0, @manager::hooks[:issue_show].length | |
|
43 | end | |
|
44 | ||
|
45 | def test_add_listener | |
|
46 | assert_equal 0, @manager::hooks[:issue_show].length | |
|
47 | @manager.add_listener(:issue_show, Proc.new { } ) | |
|
48 | assert_equal 1, @manager::hooks[:issue_show].length | |
|
49 | end | |
|
7 | 50 | end |
|
8 | 51 | |
|
9 | 52 | class Redmine::Plugin::Hook::BaseTest < Test::Unit::TestCase |
|
10 | 53 | def test_sanity |
|
11 | 54 | assert true |
|
12 | 55 | end |
|
13 | 56 | |
|
14 | 57 | def test_help_should_be_a_singleton |
|
15 | 58 | assert Redmine::Plugin::Hook::Base::Helper.include?(Singleton) |
|
16 | 59 | end |
|
17 | 60 | |
|
18 | 61 | def test_helper_should_include_actionview_helpers |
|
19 | 62 | [ActionView::Helpers::TagHelper, |
|
20 | 63 | ActionView::Helpers::FormHelper, |
|
21 | 64 | ActionView::Helpers::FormTagHelper, |
|
22 | 65 | ActionView::Helpers::FormOptionsHelper, |
|
23 | 66 | ActionView::Helpers::JavaScriptHelper, |
|
24 | 67 | ActionView::Helpers::PrototypeHelper, |
|
25 | 68 | ActionView::Helpers::NumberHelper, |
|
26 | 69 | ActionView::Helpers::UrlHelper].each do |helper| |
|
27 | 70 | assert Redmine::Plugin::Hook::Base::Helper.include?(helper), "#{helper} wasn't included." |
|
28 | 71 | end |
|
29 | 72 | end |
|
30 | 73 | end |
General Comments 0
You need to be logged in to leave comments.
Login now