Skip to content

Commit f4fc235

Browse files
committed
Added show_menu_below_id soft_root test
1 parent afd69f8 commit f4fc235

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

cms/menu.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ class SoftRootCutter(Modifier):
399399

400400
def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
401401
# only apply this modifier if we're pre-cut (since what we do is cut)
402+
# or if no id argument is provided, indicating {% show_menu_below_id %}
402403
if post_cut or root_id:
403404
return nodes
404405
selected = None

cms/tests/menu.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,36 @@ def test_not_in_navigation_num_queries(self):
881881
tpl = Template("{% load menu_tags %}{% show_menu_below_id 'a' 0 100 100 100 %}")
882882
tpl.render(context)
883883

884+
def test_menu_in_soft_root(self):
885+
"""
886+
Test for issue 3504
887+
888+
Build the following tree:
889+
890+
A
891+
|-B
892+
C (soft_root)
893+
"""
894+
a = create_page('A', 'nav_playground.html', 'en', published=True,
895+
in_navigation=True, reverse_id='a')
896+
b = create_page('B', 'nav_playground.html', 'en', parent=a,
897+
published=True, in_navigation=True)
898+
c = create_page('C', 'nav_playground.html', 'en', published=True,
899+
in_navigation=True, soft_root=True)
900+
context = self.get_context(a.get_absolute_url())
901+
tpl = Template("{% load menu_tags %}{% show_menu_below_id 'a' %}")
902+
tpl.render(context)
903+
nodes = context['children']
904+
self.assertEqual(len(nodes), 1)
905+
node = nodes[0]
906+
self.assertEqual(node.id, b.publisher_public.id)
907+
context = self.get_context(c.get_absolute_url())
908+
tpl = Template("{% load menu_tags %}{% show_menu_below_id 'a' %}")
909+
tpl.render(context)
910+
nodes = context['children']
911+
self.assertEqual(len(nodes), 1)
912+
node = nodes[0]
913+
self.assertEqual(node.id, b.publisher_public.id)
884914

885915
class ViewPermissionMenuTests(SettingsOverrideTestCase):
886916
settings_overrides = {

0 commit comments

Comments
 (0)