allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hei...@apache.org
Subject [07/39] allura git commit: [#1731] ticket:782 Don't show thumbnail for deleted post's attachment
Date Tue, 02 Jun 2015 20:06:58 GMT
[#1731] ticket:782 Don't show thumbnail for deleted post's attachment


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/e0779438
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e0779438
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e0779438

Branch: refs/heads/hs/7825
Commit: e07794389e3fed007202362e5ff1ce207470f00c
Parents: 4788e07
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed May 27 13:33:20 2015 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed May 27 13:33:20 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/attachments.py       |  2 ++
 Allura/allura/tests/functional/test_discuss.py | 13 ++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e0779438/Allura/allura/controllers/attachments.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/attachments.py b/Allura/allura/controllers/attachments.py
index c97a9d1..da25767 100644
--- a/Allura/allura/controllers/attachments.py
+++ b/Allura/allura/controllers/attachments.py
@@ -97,4 +97,6 @@ class AttachmentController(BaseController):
 
     @expose()
     def thumb(self):
+        if self.artifact.deleted:
+            raise exc.HTTPNotFound
         return self.thumbnail.serve(embed=True)

http://git-wip-us.apache.org/repos/asf/allura/blob/e0779438/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index 0471b48..74ca133 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -15,6 +15,7 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+import os
 from mock import patch
 from nose.tools import assert_in, assert_not_in, assert_equal
 
@@ -309,13 +310,19 @@ class TestAttachment(TestController):
         assert "test.txt" in r
 
     def test_deleted_post_attachment(self):
+        f = os.path.join(os.path.dirname(__file__), '..', 'data', 'user.png')
+        with open(f) as f:
+            pic = f.read()
         self.app.post(
             self.post_link + 'attach',
-            upload_files=[('file_info', 'test.txt', 'HiThere!')])
+            upload_files=[('file_info', 'user.png', pic)])
         alink = self.attach_link()
-        r = self.app.get(alink, status=200)
+        thumblink = alink + '/thumb'
+        self.app.get(alink, status=200)
+        self.app.get(thumblink, status=200)
         _, slug = self.post_link.rstrip('/reply').rsplit('/', 1)
         post = M.Post.query.get(slug=slug)
         post.deleted = True
         session(post).flush(post)
-        r = self.app.get(alink, status=404)
+        self.app.get(alink, status=404)
+        self.app.get(thumblink, status=404)


Mime
View raw message