You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/05/27 21:42:03 UTC
[7/7] allura git commit: [#1731] ticket:782 Don't show thumbnail for
deleted post's attachment
[#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/master
Commit: e07794389e3fed007202362e5ff1ce207470f00c
Parents: 4788e07
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed May 27 13:33:20 2015 +0000
Committer: Igor Bondarenko <je...@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)