applications: tarfile filename with slug & version num (#80521)
gitea/hobo/pipeline/head This commit looks good Details

This commit is contained in:
Lauréline Guérin 2023-09-11 17:39:33 +02:00
parent 1cf92f2a54
commit 8131c05977
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 5 additions and 1 deletions

View File

@ -295,7 +295,7 @@ def download(request, app_slug, version_pk=None):
else:
version = get_object_or_404(app.version_set, pk=version_pk)
response = HttpResponse(version.bundle, content_type='application/x-tar')
response['Content-Disposition'] = 'attachment; filename="%s"' % '%s.tar' % app_slug
response['Content-Disposition'] = 'attachment; filename="%s"' % '%s-%s.tar' % (app_slug, version.number)
return response

View File

@ -309,6 +309,7 @@ def test_create_application(app, admin_user, settings, analyze):
assert resp.text.count('Creating application bundle') == 1
resp = resp.click(href='/applications/manifest/test/download/%s/' % version.pk)
assert resp.content_type == 'application/x-tar'
assert resp.headers['Content-Disposition'] == 'attachment; filename="test-1.0.tar"'
assert b'"version_number": "1.0"' in resp.content
# generate again without changing version number
@ -332,6 +333,7 @@ def test_create_application(app, admin_user, settings, analyze):
assert resp.text.count('Creating application bundle') == 2
resp = resp.click(href='/applications/manifest/test/download/%s/' % same_version.pk)
assert resp.content_type == 'application/x-tar'
assert resp.headers['Content-Disposition'] == 'attachment; filename="test-1.0.tar"'
assert b'"version_number": "1.0"' in resp.content
# add an icon
@ -386,10 +388,12 @@ def test_create_application(app, admin_user, settings, analyze):
assert resp.text.count('Creating application bundle') == 3
resp = resp.click(href='/applications/manifest/test/download/%s/' % same_version.pk)
assert resp.content_type == 'application/x-tar'
assert resp.headers['Content-Disposition'] == 'attachment; filename="test-1.0.tar"'
assert b'"version_number": "1.0"' in resp.content
resp = app.get('/applications/manifest/test/versions/')
resp = resp.click(href='/applications/manifest/test/download/%s/' % version.pk)
assert resp.content_type == 'application/x-tar'
assert resp.headers['Content-Disposition'] == 'attachment; filename="test-2.0.tar"'
assert b'"version_number": "2.0"' in resp.content
resp = app.get('/applications/manifest/test/generate/')