Fixes deletion for boosts

This commit is contained in:
Mouse Reeve 2021-02-17 13:07:19 -08:00
parent 7b21a0a208
commit e8e4ed773c
2 changed files with 8 additions and 2 deletions

View file

@ -86,6 +86,10 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
def delete(self, *args, **kwargs):#pylint: disable=unused-argument
''' "delete" a status '''
if hasattr(self, 'boosted_status'):
# okay but if it's a boost really delete it
super().delete(*args, **kwargs)
return
self.deleted = True
self.deleted_date = timezone.now()
self.save()

View file

@ -138,7 +138,7 @@ class InteractionViews(TestCase):
''' undo a boost '''
view = views.Unboost.as_view()
request = self.factory.post('')
request.user = self.remote_user
request.user = self.local_user
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
status = models.Status.objects.create(
user=self.local_user, content='hi')
@ -146,7 +146,9 @@ class InteractionViews(TestCase):
self.assertEqual(models.Boost.objects.count(), 1)
self.assertEqual(models.Notification.objects.count(), 1)
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay') \
as mock:
view(request, status.id)
self.assertEqual(mock.call_count, 1)
self.assertEqual(models.Boost.objects.count(), 0)
self.assertEqual(models.Notification.objects.count(), 0)