Fix permissions when converting a user to an org

Fixes #1366
This commit is contained in:
Joseph Schorr 2016-04-14 17:39:45 -04:00
parent a65012a71e
commit c604dbd0f6
3 changed files with 45 additions and 20 deletions

View file

@ -417,6 +417,15 @@ class TestConvertToOrganization(ApiTestCase):
def test_convert(self):
self.login(READ_ACCESS_USER)
# Add at least one permission for the read-user.
read_user = model.user.get_user(READ_ACCESS_USER)
simple_repo = model.repository.get_repository(ADMIN_ACCESS_USER, 'simple')
read_role = database.Role.get(name='read')
database.RepositoryPermission.create(user=read_user, repository=simple_repo, role=read_role)
# Convert the read user into an organization.
json = self.postJsonResponse(ConvertToOrganization,
data={'adminUser': ADMIN_ACCESS_USER,
'adminPassword': 'password',
@ -436,6 +445,11 @@ class TestConvertToOrganization(ApiTestCase):
self.assertEquals(READ_ACCESS_USER, json['name'])
self.assertEquals(True, json['is_admin'])
# Verify the now-org has no permissions.
count = (database.RepositoryPermission.select()
.where(database.RepositoryPermission.user == organization)
.count())
self.assertEquals(0, count)
def test_convert_via_email(self):
self.login(READ_ACCESS_USER)