mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 09:13:14 +00:00
Fixed TypeError raised by richtext template tag
Conflicts: wagtail/wagtailcore/tests/tests.py
This commit is contained in:
parent
72e74bbb3d
commit
ec341d76ab
2 changed files with 17 additions and 1 deletions
|
|
@ -35,4 +35,6 @@ def wagtail_version():
|
|||
|
||||
@register.filter
|
||||
def richtext(value):
|
||||
return mark_safe('<div class="rich-text">' + expand_db_html(value) + '</div>')
|
||||
if value:
|
||||
return mark_safe('<div class="rich-text">' + expand_db_html(value) + '</div>')
|
||||
return ''
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from django.test import TestCase
|
|||
from django.core.cache import cache
|
||||
|
||||
from wagtail.wagtailcore.models import Page, Site
|
||||
from wagtail.wagtailcore.templatetags.wagtailcore_tags import richtext
|
||||
from wagtail.tests.models import SimplePage
|
||||
|
||||
|
||||
|
|
@ -142,3 +143,16 @@ class TestSiteRootPathsCache(TestCase):
|
|||
|
||||
# Check url
|
||||
self.assertEqual(homepage.url, '/')
|
||||
|
||||
|
||||
class TestRichtextTag(TestCase):
|
||||
|
||||
def test_typeerror(self):
|
||||
"""`richtext` fails when it's called with `value` being not a string
|
||||
or buffer.
|
||||
"""
|
||||
value = None
|
||||
|
||||
result = richtext(value)
|
||||
|
||||
self.assertEqual(result, '')
|
||||
|
|
|
|||
Loading…
Reference in a new issue