# HG changeset patch # User neko259 # Date 2014-11-18 21:10:23 # Node ID e30879950bcf73df19a08fe1fd9a98243deda604 # Parent e01941af51b59bb8f6ad4f0a4a9d27c549ab77eb Actually delete the opening post when deleting the thread diff --git a/boards/models/post.py b/boards/models/post.py --- a/boards/models/post.py +++ b/boards/models/post.py @@ -368,7 +368,7 @@ class Post(models.Model, Viewable): thread.last_edit_time = timezone.now() thread.save() - super(Post, self).delete(using) + super(Post, self).delete(using) logging.getLogger('boards.post.delete').info( 'Deleted post P#{}/{}'.format(self.id, self.get_title())) diff --git a/boards/tests/test_post.py b/boards/tests/test_post.py --- a/boards/tests/test_post.py +++ b/boards/tests/test_post.py @@ -37,9 +37,12 @@ class PostTests(TestCase): thread = opening_post.get_thread() reply = Post.objects.create_post("", "", thread=thread) - thread.delete() + opening_post.delete() - self.assertFalse(Post.objects.filter(id=reply.id).exists()) + self.assertFalse(Post.objects.filter(id=reply.id).exists(), + 'Reply was not deleted with the thread.') + self.assertFalse(Post.objects.filter(id=opening_post.id).exists(), + 'Opening post was not deleted with the thread.') def test_post_to_thread(self): """Test adding post to a thread"""