summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2008-08-30 21:30:02 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2008-08-30 21:30:02 +0000
commitae72e25b354f6cc185eeb42a81ac79b83c5a636c (patch)
tree3315a967f6e793f70ec7c2b87d380f123458b9a2 /tests
parenteebc7caa6380096f5a8402db9a6e4a324585551b (diff)
Fixed #8716: correctly handle name and email in comments from authenticated users.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8751 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/comment_tests/fixtures/comment_tests.json5
-rw-r--r--tests/regressiontests/comment_tests/tests/comment_view_tests.py16
2 files changed, 20 insertions, 1 deletions
diff --git a/tests/regressiontests/comment_tests/fixtures/comment_tests.json b/tests/regressiontests/comment_tests/fixtures/comment_tests.json
index b10326930e..6731876e22 100644
--- a/tests/regressiontests/comment_tests/fixtures/comment_tests.json
+++ b/tests/regressiontests/comment_tests/fixtures/comment_tests.json
@@ -37,7 +37,10 @@
"pk" : 100,
"fields" : {
"username" : "normaluser",
- "password" : "34ea4aaaf24efcbb4b30d27302f8657f"
+ "password" : "34ea4aaaf24efcbb4b30d27302f8657f",
+ "first_name": "Joe",
+ "last_name": "Normal",
+ "email": "joe.normal@example.com"
}
}
]
diff --git a/tests/regressiontests/comment_tests/tests/comment_view_tests.py b/tests/regressiontests/comment_tests/tests/comment_view_tests.py
index ac7a1d4a5e..bd9fb4144d 100644
--- a/tests/regressiontests/comment_tests/tests/comment_view_tests.py
+++ b/tests/regressiontests/comment_tests/tests/comment_view_tests.py
@@ -1,4 +1,5 @@
from django.conf import settings
+from django.contrib.auth.models import User
from django.contrib.comments import signals
from django.contrib.comments.models import Comment
from regressiontests.comment_tests.models import Article
@@ -84,6 +85,21 @@ 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)
+ data['name'] = data['email'] = ''
+ self.client.login(username="normaluser", password="normaluser")
+ self.response = self.client.post("/post/", data, REMOTE_ADDR="1.2.3.4")
+ self.assertEqual(self.response.status_code, 302)
+ self.assertEqual(Comment.objects.count(), 1)
+ c = Comment.objects.all()[0]
+ self.assertEqual(c.ip_address, "1.2.3.4")
+ u = User.objects.get(username='normaluser')
+ self.assertEqual(c.user, u)
+ self.assertEqual(c.user_name, u.get_full_name())
+ self.assertEqual(c.user_email, u.email)
def testPreventDuplicateComments(self):
"""Prevent posting the exact same comment twice"""