mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Fix routablepageurl to work with WAGTAIL_APPEND_SLASH = False (#3856)
This commit is contained in:
parent
030c6b9548
commit
57969731b2
@ -22,4 +22,6 @@ def routablepageurl(context, page, url_name, *args, **kwargs):
|
||||
request = context['request']
|
||||
base_url = page.relative_url(request.site)
|
||||
routed_url = page.reverse_subpage(url_name, args=args, kwargs=kwargs)
|
||||
if not base_url.endswith('/'):
|
||||
base_url += '/'
|
||||
return base_url + routed_url
|
||||
|
@ -1,5 +1,6 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import mock
|
||||
from django.core.urlresolvers import NoReverseMatch
|
||||
from django.test import RequestFactory, TestCase
|
||||
|
||||
@ -185,3 +186,11 @@ class TestRoutablePageTemplateTag(TestCase):
|
||||
'external_view', 'joe-bloggs')
|
||||
|
||||
self.assertEqual(url, self.routable_page.url + 'external/joe-bloggs/')
|
||||
|
||||
def test_templatetag_reverse_external_view_without_append_slash(self):
|
||||
with mock.patch('wagtail.wagtailcore.models.WAGTAIL_APPEND_SLASH', False):
|
||||
url = routablepageurl(self.context, self.routable_page,
|
||||
'external_view', 'joe-bloggs')
|
||||
expected = self.routable_page.url + '/' + 'external/joe-bloggs/'
|
||||
|
||||
self.assertEqual(url, expected)
|
||||
|
Loading…
Reference in New Issue
Block a user