Skip to content

Commit

Permalink
fix: missing enums are not immediately saved (#1940)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSlimvReal authored Jul 25, 2023
1 parent 484ee47 commit 5028765
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ describe("ConfigurableEnumService", () => {
let service: ConfigurableEnumService;
let mockEntityMapper: jasmine.SpyObj<EntityMapperService>;
beforeEach(async () => {
mockEntityMapper = jasmine.createSpyObj([
"save",
"loadType",
"receiveUpdates",
]);
mockEntityMapper = jasmine.createSpyObj(["loadType", "receiveUpdates"]);
mockEntityMapper.receiveUpdates.and.returnValue(NEVER);
mockEntityMapper.loadType.and.resolveTo([]);
await TestBed.configureTestingModule({
Expand All @@ -34,14 +30,12 @@ describe("ConfigurableEnumService", () => {

expect(newEnum.getId()).toEqual("new-id");
expect(newEnum.values).toEqual([]);
expect(mockEntityMapper.save).toHaveBeenCalledWith(newEnum);
// returns same enum in consecutive calls
expect(service.getEnum("new-id")).toBe(newEnum);
});

it("should not creat a new enum if the user is missing permissions", () => {
spyOn(TestBed.inject(EntityAbility), "can").and.returnValue(false);
expect(service.getEnum("new-id")).toBeUndefined();
expect(mockEntityMapper.save).not.toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class ConfigurableEnumService {
) {
const newEnum = new ConfigurableEnum(id);
this.cacheEnum(newEnum);
this.entityMapper.save(newEnum);
}
return this.enums.get(entityId);
}
Expand Down

0 comments on commit 5028765

Please sign in to comment.