summaryrefslogtreecommitdiffstats
path: root/test/unit/lib/redmine_test.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2009-11-25 05:36:44 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2009-11-25 05:36:44 +0000
commit1f06cf889990d9640f7160c4969ed074fb68a7ca (patch)
tree034ebf2c1567b0d707af669b3ccd1f403237a866 /test/unit/lib/redmine_test.rb
parent5a9528cf3d9eb4afbec81cf1d79f7134596906f1 (diff)
downloadredmine-1f06cf889990d9640f7160c4969ed074fb68a7ca.tar.gz
redmine-1f06cf889990d9640f7160c4969ed074fb68a7ca.zip
Converted Menus to a Tree structure to allow submenus.
* Bundle the rubytree gem * Patched RubyTree's TreeNode to add some additional methods. * Converted the menu rendering to walk the Tree of MenuItems to render each item * Added a menu option for :parent_menu to make this menu a child of the parent * Added a bunch of tests * Made MenuItem a subclass of Tree::TreeNode in order to use it's methods directly * Changed the exceptions in MenuItem#new to be ArgumentErrors instead of the generic RuntimeError #4250 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3090 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/lib/redmine_test.rb')
-rw-r--r--test/unit/lib/redmine_test.rb84
1 files changed, 84 insertions, 0 deletions
diff --git a/test/unit/lib/redmine_test.rb b/test/unit/lib/redmine_test.rb
new file mode 100644
index 000000000..5150da1f2
--- /dev/null
+++ b/test/unit/lib/redmine_test.rb
@@ -0,0 +1,84 @@
+# Redmine - project management software
+# Copyright (C) 2006-2009 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../../test_helper'
+
+module RedmineMenuTestHelper
+ # Assertions
+ def assert_number_of_items_in_menu(menu_name, count)
+ assert Redmine::MenuManager.items(menu_name).size >= count, "Menu has less than #{count} items"
+ end
+
+ def assert_menu_contains_item_named(menu_name, item_name)
+ assert Redmine::MenuManager.items(menu_name).collect(&:name).include?(item_name.to_sym), "Menu did not have an item named #{item_name}"
+ end
+
+ # Helpers
+ def get_menu_item(menu_name, item_name)
+ Redmine::MenuManager.items(menu_name).find {|item| item.name == item_name.to_sym}
+ end
+end
+
+class RedmineTest < Test::Unit::TestCase
+ include RedmineMenuTestHelper
+
+ def test_top_menu
+ assert_number_of_items_in_menu :top_menu, 5
+ assert_menu_contains_item_named :top_menu, :home
+ assert_menu_contains_item_named :top_menu, :my_page
+ assert_menu_contains_item_named :top_menu, :projects
+ assert_menu_contains_item_named :top_menu, :administration
+ assert_menu_contains_item_named :top_menu, :help
+ end
+
+ def test_account_menu
+ assert_number_of_items_in_menu :account_menu, 4
+ assert_menu_contains_item_named :account_menu, :login
+ assert_menu_contains_item_named :account_menu, :register
+ assert_menu_contains_item_named :account_menu, :my_account
+ assert_menu_contains_item_named :account_menu, :logout
+ end
+
+ def test_application_menu
+ assert_number_of_items_in_menu :application_menu, 0
+ end
+
+ def test_admin_menu
+ assert_number_of_items_in_menu :admin_menu, 0
+ end
+
+ def test_project_menu
+ assert_number_of_items_in_menu :project_menu, 12
+ assert_menu_contains_item_named :project_menu, :overview
+ assert_menu_contains_item_named :project_menu, :activity
+ assert_menu_contains_item_named :project_menu, :roadmap
+ assert_menu_contains_item_named :project_menu, :issues
+ assert_menu_contains_item_named :project_menu, :new_issue
+ assert_menu_contains_item_named :project_menu, :news
+ assert_menu_contains_item_named :project_menu, :documents
+ assert_menu_contains_item_named :project_menu, :wiki
+ assert_menu_contains_item_named :project_menu, :boards
+ assert_menu_contains_item_named :project_menu, :files
+ assert_menu_contains_item_named :project_menu, :repository
+ assert_menu_contains_item_named :project_menu, :settings
+ end
+
+ def test_new_issue_should_have_root_as_a_parent
+ new_issue = get_menu_item(:project_menu, :new_issue)
+ assert_equal :root, new_issue.parent.name
+ end
+end