Reuse existing files as previews, icons or featured images #161
@ -262,6 +262,7 @@ class UpdateTest(CheckFilePropertiesMixin, TestCase):
|
|||||||
extension = create_approved_version().extension
|
extension = create_approved_version().extension
|
||||||
images_count_before = File.objects.filter(type=File.TYPES.IMAGE).count()
|
images_count_before = File.objects.filter(type=File.TYPES.IMAGE).count()
|
||||||
self.assertEqual(extension.previews.count(), 0)
|
self.assertEqual(extension.previews.count(), 0)
|
||||||
|
old_user = file.user
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
**POST_DATA,
|
**POST_DATA,
|
||||||
@ -281,6 +282,8 @@ class UpdateTest(CheckFilePropertiesMixin, TestCase):
|
|||||||
self.assertEqual(extension.previews.count(), 1)
|
self.assertEqual(extension.previews.count(), 1)
|
||||||
self.assertEqual(extension.previews.first().original_hash, file.original_hash)
|
self.assertEqual(extension.previews.first().original_hash, file.original_hash)
|
||||||
self.assertEqual(extension.previews.first().pk, file.pk)
|
self.assertEqual(extension.previews.first().pk, file.pk)
|
||||||
|
file.refresh_from_db()
|
||||||
|
self.assertEqual(file.user, old_user)
|
||||||
|
|
||||||
def test_post_upload_existing_preview_file_linked_to_extension(self):
|
def test_post_upload_existing_preview_file_linked_to_extension(self):
|
||||||
file = FileFactory(
|
file = FileFactory(
|
||||||
@ -294,6 +297,7 @@ class UpdateTest(CheckFilePropertiesMixin, TestCase):
|
|||||||
images_count_before = File.objects.filter(type=File.TYPES.IMAGE).count()
|
images_count_before = File.objects.filter(type=File.TYPES.IMAGE).count()
|
||||||
self.assertEqual(extension.previews.count(), 0)
|
self.assertEqual(extension.previews.count(), 0)
|
||||||
self.assertEqual(another_extension.previews.count(), 1)
|
self.assertEqual(another_extension.previews.count(), 1)
|
||||||
|
old_user = file.user
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
**POST_DATA,
|
**POST_DATA,
|
||||||
@ -315,6 +319,8 @@ class UpdateTest(CheckFilePropertiesMixin, TestCase):
|
|||||||
self.assertEqual(extension.previews.first().pk, file.pk)
|
self.assertEqual(extension.previews.first().pk, file.pk)
|
||||||
# File is referenced as a preview by both extensions
|
# File is referenced as a preview by both extensions
|
||||||
self.assertEqual(file.preview_set.count(), 2)
|
self.assertEqual(file.preview_set.count(), 2)
|
||||||
|
file.refresh_from_db()
|
||||||
|
self.assertEqual(file.user, old_user)
|
||||||
|
|
||||||
def test_post_upload_duplicates_are_ignored_across_forms(self):
|
def test_post_upload_duplicates_are_ignored_across_forms(self):
|
||||||
extension = create_approved_version().extension
|
extension = create_approved_version().extension
|
||||||
|
Loading…
Reference in New Issue
Block a user