Add support for unattached menus (generated dynamically)

A MenuItem can define a :child_menus option with a Proc.  When the menus
are rendered, the Proc will be run and the resulting MenuItems will be
added to the page as child menus

  #4250

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3091 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis
2009-11-25 05:36:50 +00:00
parent 1f06cf8899
commit b0999e3764
4 changed files with 181 additions and 13 deletions

View File

@@ -92,6 +92,20 @@ class Redmine::MenuManager::MenuItemTest < Test::Unit::TestCase
})
end
def test_new_menu_item_should_require_a_proc_to_use_the_child_menus_option
assert_raises ArgumentError do
Redmine::MenuManager::MenuItem.new(:test_error, '/test',
{
:child_menus => ['not_a_proc']
})
end
assert Redmine::MenuManager::MenuItem.new(:test_good_child_menus, '/test',
{
:child_menus => Proc.new{}
})
end
def test_new_should_not_allow_setting_the_parent_menu_item_to_the_current_item
assert_raises ArgumentError do
Redmine::MenuManager::MenuItem.new(:test_error, '/test', { :parent_menu => :test_error })