Fixed TypeError raised by richtext template tag

Conflicts:
	wagtail/wagtailcore/tests/tests.py
This commit is contained in:
Alejandro Varas 2014-09-10 12:32:26 -03:00 committed by Karl Hobley
parent 72e74bbb3d
commit ec341d76ab
2 changed files with 17 additions and 1 deletions

View file

@ -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 ''

View file

@ -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, '')