|
@@ -1,3 +1,4 @@
|
|
|
|
+from django.contrib.auth import get_user_model
|
|
from django.core import mail
|
|
from django.core import mail
|
|
from django.urls import reverse
|
|
from django.urls import reverse
|
|
from django.utils.encoding import smart_str
|
|
from django.utils.encoding import smart_str
|
|
@@ -8,6 +9,8 @@ from misago.threads.models import ThreadParticipant
|
|
from misago.threads.test import other_user_cant_use_private_threads
|
|
from misago.threads.test import other_user_cant_use_private_threads
|
|
from misago.users.testutils import AuthenticatedUserTestCase, create_test_user
|
|
from misago.users.testutils import AuthenticatedUserTestCase, create_test_user
|
|
|
|
|
|
|
|
+User = get_user_model()
|
|
|
|
+
|
|
|
|
|
|
class StartPrivateThreadTests(AuthenticatedUserTestCase):
|
|
class StartPrivateThreadTests(AuthenticatedUserTestCase):
|
|
def setUp(self):
|
|
def setUp(self):
|
|
@@ -166,7 +169,7 @@ class StartPrivateThreadTests(AuthenticatedUserTestCase):
|
|
self.assertEqual(response.status_code, 400)
|
|
self.assertEqual(response.status_code, 400)
|
|
self.assertEqual(
|
|
self.assertEqual(
|
|
response.json(),
|
|
response.json(),
|
|
- {"to": ["BobBoberson can't participate in private threads."]},
|
|
|
|
|
|
+ {"to": ["OtherUser can't participate in private threads."]},
|
|
)
|
|
)
|
|
|
|
|
|
def test_cant_invite_blocking(self):
|
|
def test_cant_invite_blocking(self):
|
|
@@ -183,7 +186,7 @@ class StartPrivateThreadTests(AuthenticatedUserTestCase):
|
|
)
|
|
)
|
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
self.assertEqual(response.status_code, 400)
|
|
- self.assertEqual(response.json(), {"to": ["BobBoberson is blocking you."]})
|
|
|
|
|
|
+ self.assertEqual(response.json(), {"to": ["OtherUser is blocking you."]})
|
|
|
|
|
|
@patch_user_acl({"can_add_everyone_to_private_threads": 1})
|
|
@patch_user_acl({"can_add_everyone_to_private_threads": 1})
|
|
def test_cant_invite_blocking_override(self):
|
|
def test_cant_invite_blocking_override(self):
|
|
@@ -225,7 +228,7 @@ class StartPrivateThreadTests(AuthenticatedUserTestCase):
|
|
response.json(),
|
|
response.json(),
|
|
{
|
|
{
|
|
"to": [
|
|
"to": [
|
|
- "BobBoberson limits invitations to private threads to followed users."
|
|
|
|
|
|
+ "OtherUser limits invitations to private threads to followed users."
|
|
]
|
|
]
|
|
},
|
|
},
|
|
)
|
|
)
|
|
@@ -283,7 +286,7 @@ class StartPrivateThreadTests(AuthenticatedUserTestCase):
|
|
self.assertEqual(response.status_code, 400)
|
|
self.assertEqual(response.status_code, 400)
|
|
self.assertEqual(
|
|
self.assertEqual(
|
|
response.json(),
|
|
response.json(),
|
|
- {"to": ["BobBoberson is not allowing invitations to private threads."]},
|
|
|
|
|
|
+ {"to": ["OtherUser is not allowing invitations to private threads."]},
|
|
)
|
|
)
|
|
|
|
|
|
# allow us to bypass user preference check
|
|
# allow us to bypass user preference check
|
|
@@ -359,8 +362,8 @@ class StartPrivateThreadTests(AuthenticatedUserTestCase):
|
|
)
|
|
)
|
|
|
|
|
|
# other user has sync_unread_private_threads flag
|
|
# other user has sync_unread_private_threads flag
|
|
- user_to_sync = User.objects.get(sync_unread_private_threads=True)
|
|
|
|
- self.assertEqual(user_to_sync, self.other_user)
|
|
|
|
|
|
+ self.other_user.refresh_from_db()
|
|
|
|
+ self.assertTrue(self.other_user.sync_unread_private_threads)
|
|
|
|
|
|
# notification about new private thread was sent to other user
|
|
# notification about new private thread was sent to other user
|
|
self.assertEqual(len(mail.outbox), 1)
|
|
self.assertEqual(len(mail.outbox), 1)
|