generated from helsingborg-stad/gdi-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* full rework of roles: string[] => {[privilege]?: boolean} * roles {} are flattened to [] for transport and persistence
- Loading branch information
Showing
37 changed files
with
481 additions
and
207 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,4 +152,3 @@ components: | |
type: array | ||
items: | ||
type: string | ||
|
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
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
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
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 |
---|---|---|
@@ -1,29 +1,35 @@ | ||
import { getAdvertMeta } from '..' | ||
import { makeAdmin } from '../../../login' | ||
import type { HaffaUser } from '../../../login/types' | ||
import { createEmptyAdvert } from '../../mappers' | ||
|
||
describe('getAdvertMeta::canRemove', () => { | ||
const testUser: HaffaUser = { id: 'test@user', roles: [] } | ||
it('admin can remove', () => { | ||
const createUserWithRights = (id: string): HaffaUser => ({ | ||
id, | ||
roles: { canRemoveOwnAdverts: true }, | ||
}) | ||
|
||
it('with rights can remove own', () => { | ||
expect( | ||
getAdvertMeta( | ||
createEmptyAdvert({ createdBy: 'test@user' }), | ||
makeAdmin(testUser) | ||
createUserWithRights('test@user') | ||
).canRemove | ||
).toBe(true) | ||
}) | ||
it('owner may not remove', () => { | ||
it('without rights can not remove', () => { | ||
expect( | ||
getAdvertMeta(createEmptyAdvert({ createdBy: 'another@user' }), testUser) | ||
.canRemove | ||
getAdvertMeta(createEmptyAdvert({ createdBy: 'test@user' }), { | ||
id: 'test@user', | ||
}).canRemove | ||
).toBe(false) | ||
}) | ||
|
||
it('others may not remove', () => { | ||
expect( | ||
getAdvertMeta(createEmptyAdvert({ createdBy: 'another@user' }), testUser) | ||
.canRemove | ||
getAdvertMeta( | ||
createEmptyAdvert({ createdBy: 'test@user' }), | ||
createUserWithRights('another@user') | ||
).canRemove | ||
).toBe(false) | ||
}) | ||
}) |
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
Oops, something went wrong.