merge r46437 and r46946 from davisagli-features: respect the per-comment mime_type setting, and use the old cooked text/html from legacy comments when migrating
svn path=/plone.app.discussion/trunk/; revision=48356
This commit is contained in:
@@ -123,6 +123,44 @@ class CommentTest(PloneTestCase):
|
||||
comment1 = createObject('plone.Comment')
|
||||
self.assertEquals(comment1.Type(), 'Comment')
|
||||
|
||||
def test_getText(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.text = """First paragraph
|
||||
|
||||
Second paragraph"""
|
||||
self.assertEquals(comment1.getText(),
|
||||
"<p>First paragraph<br /><br /> Second paragraph</p>")
|
||||
|
||||
def test_getText_escapes_HTML(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.text = """<b>Got HTML?</b>"""
|
||||
self.assertEquals(comment1.getText(),
|
||||
"<p><b>Got HTML?</b></p>")
|
||||
|
||||
def test_getText_with_non_ascii_characters(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.text = u"""Umlaute sind ä, ö und ü."""
|
||||
self.assertEquals(comment1.getText(),
|
||||
'<p>Umlaute sind \xc3\xa4, \xc3\xb6 und \xc3\xbc.</p>')
|
||||
|
||||
def test_getText_doesnt_link(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.text = "Go to http://www.plone.org"
|
||||
self.assertEquals(comment1.getText(),
|
||||
"<p>Go to http://www.plone.org</p>")
|
||||
|
||||
def test_getText_uses_comment_mime_type(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.text = "Go to http://www.plone.org"
|
||||
comment1.mime_type = 'text/x-web-intelligent'
|
||||
self.assertEquals(comment1.getText(),
|
||||
'Go to <a href="http://www.plone.org" rel="nofollow">http://www.plone.org</a>')
|
||||
|
||||
def test_getText_w_custom_targetMimetype(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.text = 'para'
|
||||
self.assertEquals(comment1.getText(targetMimetype='text/plain'), 'para')
|
||||
|
||||
def test_traversal(self):
|
||||
# make sure comments are traversable, have an id, absolute_url and
|
||||
# physical path
|
||||
|
||||
@@ -228,28 +228,6 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
settings = registry.forInterface(IDiscussionSettings)
|
||||
settings.globally_enabled = True
|
||||
|
||||
def test_cook(self):
|
||||
text = """First paragraph
|
||||
|
||||
Second paragraph"""
|
||||
self.assertEquals(self.viewlet.cook(text),
|
||||
"<p>First paragraph<br /><br /> Second paragraph</p>")
|
||||
|
||||
def test_cook_no_html(self):
|
||||
text = """<b>Got HTML?</b>"""
|
||||
self.assertEquals(self.viewlet.cook(text),
|
||||
"<p><b>Got HTML?</b></p>")
|
||||
|
||||
def test_cook_with_no_ascii_characters(self):
|
||||
text = """Umlaute sind ä, ö und ü."""
|
||||
self.assertEquals(self.viewlet.cook(text),
|
||||
"<p>Umlaute sind \xc3\xa4, \xc3\xb6 und \xc3\xbc.</p>")
|
||||
|
||||
def test_cook_links(self):
|
||||
text = "Go to http://www.plone.org"
|
||||
self.assertEquals(self.viewlet.cook(text),
|
||||
"<p>Go to http://www.plone.org</p>")
|
||||
|
||||
def test_can_reply(self):
|
||||
# Portal owner can reply
|
||||
self.failUnless(self.viewlet.can_reply())
|
||||
|
||||
@@ -69,7 +69,8 @@ class MigrationTest(PloneTestCase):
|
||||
comment1 = conversation.values()[0]
|
||||
self.assert_(IComment.providedBy(comment1))
|
||||
self.assertEquals(comment1.Title(), 'Jim on Document 1')
|
||||
self.assertEquals(comment1.text, 'My Text')
|
||||
self.assertEquals(comment1.text, '<p>My Text</p>\n')
|
||||
self.assertEquals(comment1.mime_type, 'text/html')
|
||||
self.assertEquals(comment1.Creator(), 'Jim')
|
||||
self.assertEquals(comment1.creation_date,
|
||||
datetime(2003, 3, 11, 9, 28, 6))
|
||||
|
||||
Reference in New Issue
Block a user