##// END OF EJS Templates
remove trailing white-spaces from test/unit/lib/redmine/menu_manager/menu_item_test.rb....
Toshi MARUYAMA -
r6673:8ad8562a349f
parent child
Show More
@@ -1,122 +1,122
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2009 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../../../../test_helper', __FILE__)
19 19
20 20 module RedmineMenuTestHelper
21 21 # Helpers
22 22 def get_menu_item(menu_name, item_name)
23 23 Redmine::MenuManager.items(menu_name).find {|item| item.name == item_name.to_sym}
24 24 end
25 25 end
26 26
27 27 class Redmine::MenuManager::MenuItemTest < ActiveSupport::TestCase
28 28 include RedmineMenuTestHelper
29 29
30 30 Redmine::MenuManager.map :test_menu do |menu|
31 31 menu.push(:parent, '/test', { })
32 32 menu.push(:child_menu, '/test', { :parent => :parent})
33 33 menu.push(:child2_menu, '/test', { :parent => :parent})
34 34 end
35
35
36 36 context "MenuItem#caption" do
37 37 should "be tested"
38 38 end
39 39
40 40 context "MenuItem#html_options" do
41 41 should "be tested"
42 42 end
43 43
44 44 # context new menu item
45 45 def test_new_menu_item_should_require_a_name
46 46 assert_raises ArgumentError do
47 47 Redmine::MenuManager::MenuItem.new
48 48 end
49 49 end
50 50
51 51 def test_new_menu_item_should_require_an_url
52 52 assert_raises ArgumentError do
53 53 Redmine::MenuManager::MenuItem.new(:test_missing_url)
54 54 end
55 55 end
56 56
57 57 def test_new_menu_item_should_require_the_options
58 58 assert_raises ArgumentError do
59 59 Redmine::MenuManager::MenuItem.new(:test_missing_options, '/test')
60 60 end
61 61 end
62 62
63 63 def test_new_menu_item_with_all_required_parameters
64 64 assert Redmine::MenuManager::MenuItem.new(:test_good_menu, '/test', {})
65 65 end
66 66
67 67 def test_new_menu_item_should_require_a_proc_to_use_for_the_if_condition
68 68 assert_raises ArgumentError do
69 69 Redmine::MenuManager::MenuItem.new(:test_error, '/test',
70 70 {
71 71 :if => ['not_a_proc']
72 72 })
73 73 end
74 74
75 75 assert Redmine::MenuManager::MenuItem.new(:test_good_if, '/test',
76 76 {
77 77 :if => Proc.new{}
78 78 })
79 79 end
80 80
81 81 def test_new_menu_item_should_allow_a_hash_for_extra_html_options
82 82 assert_raises ArgumentError do
83 83 Redmine::MenuManager::MenuItem.new(:test_error, '/test',
84 84 {
85 85 :html => ['not_a_hash']
86 86 })
87 87 end
88 88
89 89 assert Redmine::MenuManager::MenuItem.new(:test_good_html, '/test',
90 90 {
91 91 :html => { :onclick => 'doSomething'}
92 92 })
93 93 end
94 94
95 95 def test_new_menu_item_should_require_a_proc_to_use_the_children_option
96 96 assert_raises ArgumentError do
97 97 Redmine::MenuManager::MenuItem.new(:test_error, '/test',
98 98 {
99 99 :children => ['not_a_proc']
100 100 })
101 101 end
102 102
103 103 assert Redmine::MenuManager::MenuItem.new(:test_good_children, '/test',
104 104 {
105 105 :children => Proc.new{}
106 106 })
107 107 end
108 108
109 109 def test_new_should_not_allow_setting_the_parent_item_to_the_current_item
110 110 assert_raises ArgumentError do
111 111 Redmine::MenuManager::MenuItem.new(:test_error, '/test', { :parent => :test_error })
112 112 end
113 113 end
114 114
115 115 def test_has_children
116 116 parent_item = get_menu_item(:test_menu, :parent)
117 117 assert parent_item.hasChildren?
118 118 assert_equal 2, parent_item.children.size
119 119 assert_equal get_menu_item(:test_menu, :child_menu), parent_item.children[0]
120 120 assert_equal get_menu_item(:test_menu, :child2_menu), parent_item.children[1]
121 121 end
122 122 end
General Comments 0
You need to be logged in to leave comments. Login now