Add missing tests for Redmine::MenuManager::Mapper#initialize.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11772 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Baptiste Barth 2013-05-03 00:40:41 +00:00
parent 208d6d881c
commit 953e4b4abf
2 changed files with 14 additions and 1 deletions

View File

@ -221,6 +221,8 @@ module Redmine
end
class Mapper
attr_reader :menu, :menu_items
def initialize(menu, items)
items[menu] ||= MenuNode.new(:root, {})
@menu = menu

View File

@ -19,7 +19,18 @@ require File.expand_path('../../../../../test_helper', __FILE__)
class Redmine::MenuManager::MapperTest < ActiveSupport::TestCase
context "Mapper#initialize" do
should "be tested"
should "define a root MenuNode if menu is not present in items" do
menu_mapper = Redmine::MenuManager::Mapper.new(:test_menu, {})
node = menu_mapper.menu_items
assert_not_nil node
assert_equal :root, node.name
end
should "use existing MenuNode if present" do
node = "foo" # just an arbitrary reference
menu_mapper = Redmine::MenuManager::Mapper.new(:test_menu, {:test_menu => node})
assert_equal node, menu_mapper.menu_items
end
end
def test_push_onto_root