-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove user from project (#5383)
Removing a user from a project was impossible if you only had 1 owner. It worked fine when having more than an owner. This should fix it and we'll add tests later
- Loading branch information
1 parent
c9a3f33
commit 818a618
Showing
2 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1048,6 +1048,44 @@ describe('ensure project has at least one owner', () => { | |
); | ||
}); | ||
|
||
test('should be able to remove member user from the project when another is owner', async () => { | ||
const project = { | ||
id: 'remove-users-members-allowed', | ||
name: 'New project', | ||
description: 'Blah', | ||
mode: 'open' as const, | ||
defaultStickiness: 'clientId', | ||
}; | ||
await projectService.createProject(project, user); | ||
|
||
const memberRole = await stores.roleStore.getRoleByName( | ||
RoleName.MEMBER, | ||
); | ||
|
||
const memberUser = await stores.userStore.insert({ | ||
name: 'Some Name', | ||
email: '[email protected]', | ||
}); | ||
|
||
await projectService.addAccess( | ||
project.id, | ||
[memberRole.id], | ||
[], | ||
[memberUser.id], | ||
'test', | ||
); | ||
|
||
const usersBefore = await projectService.getProjectUsers(project.id); | ||
await projectService.removeUserAccess( | ||
project.id, | ||
memberUser.id, | ||
'test', | ||
); | ||
const usersAfter = await projectService.getProjectUsers(project.id); | ||
expect(usersBefore).toHaveLength(2); | ||
expect(usersAfter).toHaveLength(1); | ||
}); | ||
|
||
test('should not update role for user on project when she is the owner', async () => { | ||
const project = { | ||
id: 'update-users-not-allowed', | ||
|