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

Keep delete logbook to allow recovery #312

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,14 @@ describe('Logbook', function (this: Suite) {
.expect(404);
});

it('delete snippet by id with token should return 204', async () => {
await client
.delete(`/logbooks/${logbookSnippetId}`)
.set('Authorization', 'Bearer ' + adminToken)
.set('Content-Type', 'application/json')
.expect(204);
});

it('restore snippet by id without token should return 401', async () => {
await client
.patch(`/logbooks/${logbookSnippetId}/restore`)
Expand All @@ -410,6 +418,15 @@ describe('Logbook', function (this: Suite) {
.set('Authorization', 'Bearer ' + token)
.set('Content-Type', 'application/json')
.expect(204);
await client
.get(`/logbooks/${logbookSnippetId}`)
.set('Authorization', 'Bearer ' + token)
.set('Content-Type', 'application/json')
.expect(200)
.then(result => expect(result.body.id).to.eql(logbookSnippetId))
.catch(err => {
throw err;
});
});

it('post a logbook with authentication and should create default ACLS from parent', async () => {
Expand Down
2 changes: 1 addition & 1 deletion sci-log-db/src/controllers/logbook.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class LogbookController {
},
})
async deleteById(@param.path.string('id') id: string): Promise<void> {
await this.logbookRepository.deleteById(id, {
await this.logbookRepository.deleteByIdWithHistory(id, {
currentUser: this.user,
});
}
Expand Down
Loading