summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-05-08 06:48:36 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-05-08 06:48:36 +0000
commit8cbfeddeb011f3731152b7b2512ec1beba62b919 (patch)
treeee3a3cbb33a7cf32c3bd2c0863a6d90b0e882966 /test/unit
parent9cfb319c43be36e0921fba9c0ac155fb72f0dc34 (diff)
downloadredmine-8cbfeddeb011f3731152b7b2512ec1beba62b919.tar.gz
redmine-8cbfeddeb011f3731152b7b2512ec1beba62b919.zip
Child nodes should only be rendered if the user is actually authorized to see them (#15880).
Patch by Jan Schulz-Hofen. git-svn-id: http://svn.redmine.org/redmine/trunk@15393 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/lib/redmine/menu_manager/menu_helper_test.rb50
1 files changed, 48 insertions, 2 deletions
diff --git a/test/unit/lib/redmine/menu_manager/menu_helper_test.rb b/test/unit/lib/redmine/menu_manager/menu_helper_test.rb
index 975991eb5..404ec6406 100644
--- a/test/unit/lib/redmine/menu_manager/menu_helper_test.rb
+++ b/test/unit/lib/redmine/menu_manager/menu_helper_test.rb
@@ -119,7 +119,7 @@ class Redmine::MenuManager::MenuHelperTest < ActionView::TestCase
User.current = User.find(2)
parent_node = Redmine::MenuManager::MenuItem.new(:parent_node,
- '/test',
+ {:controller => 'issues', :action => 'index'},
{
:children => Proc.new {|p|
children = []
@@ -131,7 +131,7 @@ class Redmine::MenuManager::MenuHelperTest < ActionView::TestCase
})
parent_node << Redmine::MenuManager::MenuItem.new(:child_node,
- '/test',
+ {:controller => 'issues', :action => 'index'},
{
:children => Proc.new {|p|
children = []
@@ -163,6 +163,52 @@ class Redmine::MenuManager::MenuHelperTest < ActionView::TestCase
end
end
+ def test_render_menu_node_with_allowed_and_unallowed_unattached_children
+ User.current = User.find(2)
+
+ parent_node = Redmine::MenuManager::MenuItem.new(:parent_node,
+ {:controller => 'issues', :action => 'index'},
+ {
+ :children => Proc.new {|p|
+ [
+ Redmine::MenuManager::MenuItem.new("test_child_allowed", {:controller => 'issues', :action => 'index'}, {}),
+ Redmine::MenuManager::MenuItem.new("test_child_unallowed", {:controller => 'issues', :action => 'unallowed'}, {}),
+ ]
+ }
+ })
+
+ @output_buffer = render_menu_node(parent_node, Project.find(1))
+
+ assert_select("li") do
+ assert_select("a.parent-node", "Parent node")
+ assert_select("ul.menu-children.unattached") do
+ assert_select("li a.test-child-allowed", "Test child allowed")
+ assert_select("li a.test-child-unallowed", false)
+ end
+ end
+ end
+
+ def test_render_menu_node_with_allowed_and_unallowed_standard_children
+ User.current = User.find(6)
+
+ Redmine::MenuManager.map :some_menu do |menu|
+ menu.push(:parent_node, {:controller => 'issues', :action => 'index'}, { })
+ menu.push(:test_child_allowed, {:controller => 'issues', :action => 'index'}, {:parent => :parent_node})
+ menu.push(:test_child_unallowed, {:controller => 'issues', :action => 'new'}, {:parent => :parent_node})
+ end
+
+ @output_buffer = render_menu(:some_menu, Project.find(1))
+
+ assert_select("li") do
+ assert_select("a.parent-node", "Parent node")
+ assert_select("ul.menu-children.unattached", false)
+ assert_select("ul.menu-children") do
+ assert_select("li a.test-child-allowed", "Test child allowed")
+ assert_select("li a.test-child-unallowed", false)
+ end
+ end
+ end
+
def test_render_menu_node_with_children_without_an_array
parent_node = Redmine::MenuManager::MenuItem.new(:parent_node,
'/test',