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:
David Glick
2011-04-02 19:51:37 +00:00
parent bf5946367a
commit eb004aab44
11 changed files with 79 additions and 47 deletions
@@ -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>&lt;b&gt;Got HTML?&lt;/b&gt;</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>&lt;b&gt;Got HTML?&lt;/b&gt;</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())
+2 -1
View File
@@ -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))