##// END OF EJS Templates
Replace Test::Unit::TestCase with ActiveSupport::TestCase. #5477...
Jean-Baptiste Barth -
r3812:bc5d32d6de2c
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.dirname(__FILE__) + '/../../../../test_helper'
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 class Redmine::MenuManager::MenuItemTest < Test::Unit::TestCase
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
@@ -1,32 +1,28
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.dirname(__FILE__) + '/../../../test_helper'
19 19
20 class Redmine::MenuManagerTest < Test::Unit::TestCase
20 class Redmine::MenuManagerTest < ActiveSupport::TestCase
21 21 context "MenuManager#map" do
22 22 should "be tested"
23 23 end
24 24
25 25 context "MenuManager#items" do
26 26 should "be tested"
27 27 end
28
29 should "be tested" do
30 assert true
31 end
32 28 end
@@ -1,84 +1,84
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.dirname(__FILE__) + '/../../test_helper'
19 19
20 20 module RedmineMenuTestHelper
21 21 # Assertions
22 22 def assert_number_of_items_in_menu(menu_name, count)
23 23 assert Redmine::MenuManager.items(menu_name).size >= count, "Menu has less than #{count} items"
24 24 end
25 25
26 26 def assert_menu_contains_item_named(menu_name, item_name)
27 27 assert Redmine::MenuManager.items(menu_name).collect(&:name).include?(item_name.to_sym), "Menu did not have an item named #{item_name}"
28 28 end
29 29
30 30 # Helpers
31 31 def get_menu_item(menu_name, item_name)
32 32 Redmine::MenuManager.items(menu_name).find {|item| item.name == item_name.to_sym}
33 33 end
34 34 end
35 35
36 class RedmineTest < Test::Unit::TestCase
36 class RedmineTest < ActiveSupport::TestCase
37 37 include RedmineMenuTestHelper
38 38
39 39 def test_top_menu
40 40 assert_number_of_items_in_menu :top_menu, 5
41 41 assert_menu_contains_item_named :top_menu, :home
42 42 assert_menu_contains_item_named :top_menu, :my_page
43 43 assert_menu_contains_item_named :top_menu, :projects
44 44 assert_menu_contains_item_named :top_menu, :administration
45 45 assert_menu_contains_item_named :top_menu, :help
46 46 end
47 47
48 48 def test_account_menu
49 49 assert_number_of_items_in_menu :account_menu, 4
50 50 assert_menu_contains_item_named :account_menu, :login
51 51 assert_menu_contains_item_named :account_menu, :register
52 52 assert_menu_contains_item_named :account_menu, :my_account
53 53 assert_menu_contains_item_named :account_menu, :logout
54 54 end
55 55
56 56 def test_application_menu
57 57 assert_number_of_items_in_menu :application_menu, 0
58 58 end
59 59
60 60 def test_admin_menu
61 61 assert_number_of_items_in_menu :admin_menu, 0
62 62 end
63 63
64 64 def test_project_menu
65 65 assert_number_of_items_in_menu :project_menu, 12
66 66 assert_menu_contains_item_named :project_menu, :overview
67 67 assert_menu_contains_item_named :project_menu, :activity
68 68 assert_menu_contains_item_named :project_menu, :roadmap
69 69 assert_menu_contains_item_named :project_menu, :issues
70 70 assert_menu_contains_item_named :project_menu, :new_issue
71 71 assert_menu_contains_item_named :project_menu, :news
72 72 assert_menu_contains_item_named :project_menu, :documents
73 73 assert_menu_contains_item_named :project_menu, :wiki
74 74 assert_menu_contains_item_named :project_menu, :boards
75 75 assert_menu_contains_item_named :project_menu, :files
76 76 assert_menu_contains_item_named :project_menu, :repository
77 77 assert_menu_contains_item_named :project_menu, :settings
78 78 end
79 79
80 80 def test_new_issue_should_have_root_as_a_parent
81 81 new_issue = get_menu_item(:project_menu, :new_issue)
82 82 assert_equal :root, new_issue.parent.name
83 83 end
84 84 end
General Comments 0
You need to be logged in to leave comments. Login now