mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-24 02:39:20 -05:00
fixed broken test for good and improved file api
This commit is contained in:
@@ -23,7 +23,15 @@ class TestViewsApi(TestViews):
|
||||
self.assertEqual(self.superuser_client.get(url).status_code, 200)
|
||||
|
||||
def test_file_permission(self):
|
||||
url = reverse('api_get_recipe_file', args=[1])
|
||||
recipe = Recipe.objects.create(
|
||||
internal=False,
|
||||
link='test',
|
||||
working_time=1,
|
||||
waiting_time=1,
|
||||
created_by=auth.get_user(self.user_client_1)
|
||||
)
|
||||
|
||||
url = reverse('api_get_recipe_file', args=[recipe.pk])
|
||||
|
||||
self.assertEqual(self.anonymous_client.get(url).status_code, 302)
|
||||
self.assertEqual(self.guest_client_1.get(url).status_code, 200)
|
||||
|
||||
@@ -402,10 +402,10 @@ def get_external_file_link(request, recipe_id):
|
||||
@group_required('guest')
|
||||
def get_recipe_file(request, recipe_id):
|
||||
recipe = Recipe.objects.get(id=recipe_id)
|
||||
# if not recipe.cors_link:
|
||||
# update_recipe_links(recipe)
|
||||
|
||||
return FileResponse(get_recipe_provider(recipe).get_file(recipe))
|
||||
if recipe.storage:
|
||||
return FileResponse(get_recipe_provider(recipe).get_file(recipe))
|
||||
else:
|
||||
return FileResponse()
|
||||
|
||||
|
||||
@group_required('user')
|
||||
|
||||
Reference in New Issue
Block a user