summaryrefslogtreecommitdiff
path: root/tests/regressiontests/comment_tests
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-10-05 05:07:32 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-10-05 05:07:32 +0000
commit227a93b64f582d62087ecbb19d281b9c6e5a2dcf (patch)
tree0c673df8db67fdc18e943251b5a8c4b1c8e69007 /tests/regressiontests/comment_tests
parent16d0a615c49830624c026b27607e46fc329ef4f4 (diff)
Fixed #8803 -- Allow authenticated users without first_name/last_name values set to post comments.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9118 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/comment_tests')
-rw-r--r--tests/regressiontests/comment_tests/tests/comment_view_tests.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/regressiontests/comment_tests/tests/comment_view_tests.py b/tests/regressiontests/comment_tests/tests/comment_view_tests.py
index bd9fb4144d..f82a5e17d8 100644
--- a/tests/regressiontests/comment_tests/tests/comment_view_tests.py
+++ b/tests/regressiontests/comment_tests/tests/comment_view_tests.py
@@ -85,7 +85,7 @@ class CommentViewTests(CommentTestCase):
c = Comment.objects.all()[0]
self.assertEqual(c.ip_address, "1.2.3.4")
self.assertEqual(c.comment, "This is my comment")
-
+
def testPostAsAuthenticatedUser(self):
a = Article.objects.get(pk=1)
data = self.getValidData(a)
@@ -101,6 +101,23 @@ class CommentViewTests(CommentTestCase):
self.assertEqual(c.user_name, u.get_full_name())
self.assertEqual(c.user_email, u.email)
+ def testPostAsAuthenticatedUserWithoutFullname(self):
+ """
+ Check that the user's name in the comment is populated for
+ authenticated users without first_name and last_name.
+ """
+ user = User.objects.create_user(username='jane_other',
+ email='jane@example.com', password='jane_other')
+ a = Article.objects.get(pk=1)
+ data = self.getValidData(a)
+ data['name'] = data['email'] = ''
+ self.client.login(username="jane_other", password="jane_other")
+ self.response = self.client.post("/post/", data, REMOTE_ADDR="1.2.3.4")
+ c = Comment.objects.get(user=user)
+ self.assertEqual(c.ip_address, "1.2.3.4")
+ self.assertEqual(c.user_name, 'jane_other')
+ user.delete()
+
def testPreventDuplicateComments(self):
"""Prevent posting the exact same comment twice"""
a = Article.objects.get(pk=1)
@@ -131,7 +148,7 @@ class CommentViewTests(CommentTestCase):
# Post a comment and check the signals
self.testCreateValidComment()
self.assertEqual(received_signals, excepted_signals)
-
+
def testWillBePostedSignal(self):
"""
Test that the comment_will_be_posted signal can prevent the comment from