From 06df69887f2636514646b4d566c8820b9c300f95 Mon Sep 17 00:00:00 2001 From: zhengxie Date: Mon, 9 Nov 2015 16:36:40 +0800 Subject: [PATCH] [file] Rename send_file_download_msg to send_file_access_msg --- seahub/views/file.py | 2 +- .../views/{test_view_file.py => test_view_lib_file.py} | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) rename tests/seahub/views/{test_view_file.py => test_view_lib_file.py} (96%) diff --git a/seahub/views/file.py b/seahub/views/file.py index 556b44ba25..2fe75dae2b 100644 --- a/seahub/views/file.py +++ b/seahub/views/file.py @@ -400,7 +400,7 @@ def _file_view(request, repo_id, path): use_onetime=True) dl_url = gen_file_get_url(token, u_filename) # send stats message - send_file_download_msg(request, repo, path, 'web') + send_file_access_msg(request, repo, path, 'web') return HttpResponseRedirect(dl_url) # Get file view raw path, ``user_perm`` is not used anymore. diff --git a/tests/seahub/views/test_view_file.py b/tests/seahub/views/test_view_lib_file.py similarity index 96% rename from tests/seahub/views/test_view_file.py rename to tests/seahub/views/test_view_lib_file.py index 5074ddcd4c..51704f44f8 100644 --- a/tests/seahub/views/test_view_file.py +++ b/tests/seahub/views/test_view_lib_file.py @@ -6,7 +6,7 @@ from django.core.urlresolvers import reverse from seahub.test_utils import BaseTestCase -class ViewFileTest(BaseTestCase): +class ViewLibFileTest(BaseTestCase): def setUp(self): # self.login_as(self.user) pass @@ -219,3 +219,11 @@ class ViewFileTest(BaseTestCase): for _ in range(3): # token for video is not one time only r = requests.get(raw_path) self.assertEqual(200, r.status_code) + + def test_can_download(self): + self.login_as(self.user) + + url = reverse('view_lib_file', args=[self.repo.id, self.file]) + '?dl=1' + resp = self.client.get(url) + self.assertEqual(302, resp.status_code) + assert '8082/files/' in resp.get('location')