forked from mirrors/bookwyrm
Fixes deletion for boosts
This commit is contained in:
parent
7b21a0a208
commit
e8e4ed773c
2 changed files with 8 additions and 2 deletions
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue