diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-03-17 17:18:15 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-03-17 17:18:15 -0500 |
commit | 16fca040d5d27879f244ded2b7455acfb7b6405f (patch) | |
tree | 65efa3cbc225c7ca1eb64820e295942638d5f26b | |
parent | 2011f2d89eebd56a5b141ccedb0968b018459bc1 (diff) | |
parent | a0a7f87f625ca29ccddc123eb6540aa15a779eb7 (diff) | |
download | mediagoblin-16fca040d5d27879f244ded2b7455acfb7b6405f.tar.lz mediagoblin-16fca040d5d27879f244ded2b7455acfb7b6405f.tar.xz mediagoblin-16fca040d5d27879f244ded2b7455acfb7b6405f.zip |
Merge remote-tracking branch 'brett/bug264-delete-comments-with-media'
-rw-r--r-- | mediagoblin/tests/test_submission.py | 15 | ||||
-rw-r--r-- | mediagoblin/user_pages/views.py | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/mediagoblin/tests/test_submission.py b/mediagoblin/tests/test_submission.py index 2f11bdfb..1f56779e 100644 --- a/mediagoblin/tests/test_submission.py +++ b/mediagoblin/tests/test_submission.py @@ -180,6 +180,18 @@ class TestSubmission: # Does media entry exist? assert_true(media) + # Add a comment, so we can test for its deletion later. + get_comments = lambda: list( + request.db.MediaComment.find({'media_entry': media._id})) + assert_false(get_comments()) + response = self.test_app.post( + request.urlgen('mediagoblin.user_pages.media_post_comment', + user=self.test_user.username, + media=media._id), + {'comment_content': 'i love this test'}) + response.follow() + assert_true(get_comments()) + # Do not confirm deletion # --------------------------------------------------- response = self.test_app.post( @@ -219,6 +231,9 @@ class TestSubmission: request.db.MediaEntry.find( {'_id': media._id}).count()) + # How about the comment? + assert_false(get_comments()) + def test_malicious_uploads(self): # Test non-suppoerted file with non-supported extension # ----------------------------------------------------- diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index 530dea64..6eff684c 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -173,6 +173,10 @@ def media_confirm_delete(request, media): if form.confirm.data is True: username = media.get_uploader.username + # Delete all the associated comments + for comment in media.get_comments(): + comment.delete() + # Delete all files on the public storage delete_media_files(media) |