Intitial teams support #147

Merged
Oleg-Komarov merged 34 commits from teams-support into main 2024-05-23 19:43:54 +02:00
Showing only changes of commit 9b5a5bf976 - Show all commits

View File

@ -2,9 +2,10 @@ from django.test import TestCase
from django.urls import reverse
from common.tests.factories.extensions import create_version
from common.tests.factories.teams import TeamFactory
from common.tests.factories.users import UserFactory
from constants.base import TEAM_ROLE_MANAGER
from constants.base import TEAM_ROLE_MANAGER, TEAM_ROLE_MEMBER
from teams.models import TeamsUsers
@ -31,3 +32,21 @@ class TeamLeaveTest(TestCase):
self.client.post(reverse('teams:leave-team', args=[team.slug]))
user.refresh_from_db()
self.assertEqual(user.teams.count(), 0)
def test_extensions_lose_team_assignment(self):
team = TeamFactory(slug='test-team')
user = UserFactory()
TeamsUsers(team=team, user=user, role=TEAM_ROLE_MEMBER).save()
extension = create_version().extension
extension.team = team
extension.authors.add(user)
extension.save()
self.client.force_login(user)
self.client.post(reverse('teams:leave-team', args=[team.slug]))
user.refresh_from_db()
self.assertEqual(user.teams.count(), 0)
extension.refresh_from_db()
self.assertIsNone(extension.team)