patch for reverse lazy url in wagtailadmin menu

pull/1998/merge
Brian 2015-12-04 12:50:06 +08:00 zatwierdzone przez Karl Hobley
rodzic c01a0952a2
commit dee427713e
2 zmienionych plików z 16 dodań i 2 usunięć

Wyświetl plik

@ -35,7 +35,7 @@ class MenuItem(with_metaclass(MediaDefiningClass)):
return True
def is_active(self, request):
return request.path.startswith(self.url)
return request.path.startswith(text_type(self.url))
def render_html(self, request):
return render_to_string(self.template, {

Wyświetl plik

@ -15,6 +15,10 @@ from wagtail.tests.utils import WagtailTestUtils
from wagtail.wagtailcore.models import Page
from wagtail.wagtailadmin.utils import send_mail
from django.core.urlresolvers import reverse_lazy
from wagtail.wagtailadmin.menu import MenuItem
from django.utils.translation import ugettext_lazy as _
class TestHome(TestCase, WagtailTestUtils):
def setUp(self):
@ -193,5 +197,15 @@ class TestTagsAutocomplete(TestCase, WagtailTestUtils):
self.assertEqual(response.status_code, 200)
self.assertEqual(response['Content-Type'], 'application/json')
data = json.loads(response.content.decode('utf-8'))
self.assertEqual(data, [])
class TestMenuItem(TestCase, WagtailTestUtils):
def setUp(self):
self.login()
response = self.client.get(reverse('wagtailadmin_home'))
self.request = response.wsgi_request
def test_menuitem_reverse_lazy_url_pass(self):
menuitem = MenuItem(_('Test'), reverse_lazy('wagtailadmin_home'))
self.assertEqual(menuitem.is_active(self.request), True)