Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guard: fix tests on CanAccessGuard #869

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions projects/admin/src/app/guard/can-access.guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,19 @@ describe('CanAccessGuard', () => {
});
}));

it('should return true if the item is part of the same organization', () => {
it('should return true if the item is part of the same organization', fakeAsync(() => {
spyOn(recordService, 'getRecord').and.returnValue(of(record));
guard.canActivate(activatedRouteSnapshotSpy)
.subscribe((access: boolean) => {
tick();
expect(access).toBeTruthy();
});
});
}));

it('should redirect to error 403 if the item does not belong to the same organization', fakeAsync(() => {
record.metadata.organisation.$ref = 'https://localhost/api/organisations/2';
spyOn(recordService, 'getRecord').and.returnValue(of(record));
const recordClone = cloneDeep(record);
recordClone.metadata.organisation.$ref = 'https://localhost/api/organisations/2';
spyOn(recordService, 'getRecord').and.returnValue(of(recordClone));
guard.canActivate(activatedRouteSnapshotSpy).subscribe(() => {
tick();
expect(router.url).toBe('/errors/403');
Expand Down