Intitial teams support #147
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user