mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-27 03:58:02 -05:00
Merge pull request #709 from hedgedoc/fix/api-notes-metadata
This commit is contained in:
commit
0d95c29df2
4 changed files with 5 additions and 3 deletions
|
@ -346,7 +346,7 @@ paths:
|
||||||
content:
|
content:
|
||||||
text/plain:
|
text/plain:
|
||||||
example: my-note
|
example: my-note
|
||||||
/notes/{note}/permissions:
|
/notes/{note}/metadata/permissions:
|
||||||
put:
|
put:
|
||||||
tags: [ note ]
|
tags: [ note ]
|
||||||
summary: Set permissions of a note
|
summary: Set permissions of a note
|
||||||
|
|
|
@ -115,7 +115,7 @@ export class NotesController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put(':noteIdOrAlias/permissions')
|
@Put(':noteIdOrAlias/metadata/permissions')
|
||||||
async updateNotePermissions(
|
async updateNotePermissions(
|
||||||
@Param('noteIdOrAlias') noteIdOrAlias: string,
|
@Param('noteIdOrAlias') noteIdOrAlias: string,
|
||||||
@Body() updateDto: NotePermissionsUpdateDto,
|
@Body() updateDto: NotePermissionsUpdateDto,
|
||||||
|
|
|
@ -195,6 +195,7 @@ export class NotesService {
|
||||||
revisions.push(Revision.create(noteContent, noteContent));
|
revisions.push(Revision.create(noteContent, noteContent));
|
||||||
note.revisions = Promise.resolve(revisions);
|
note.revisions = Promise.resolve(revisions);
|
||||||
await this.noteRepository.save(note);
|
await this.noteRepository.save(note);
|
||||||
|
return this.toNoteDto(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getNoteMetadata(noteIdOrAlias: string): Promise<NoteMetadataDto> {
|
async getNoteMetadata(noteIdOrAlias: string): Promise<NoteMetadataDto> {
|
||||||
|
|
|
@ -109,7 +109,7 @@ describe('Notes', () => {
|
||||||
|
|
||||||
it(`PUT /notes/{note}`, async () => {
|
it(`PUT /notes/{note}`, async () => {
|
||||||
await notesService.createNote('This is a test note.', 'test4');
|
await notesService.createNote('This is a test note.', 'test4');
|
||||||
await request(app.getHttpServer())
|
const response = await request(app.getHttpServer())
|
||||||
.put('/notes/test4')
|
.put('/notes/test4')
|
||||||
.set('Content-Type', 'text/markdown')
|
.set('Content-Type', 'text/markdown')
|
||||||
.send('New note text')
|
.send('New note text')
|
||||||
|
@ -117,6 +117,7 @@ describe('Notes', () => {
|
||||||
await expect(
|
await expect(
|
||||||
(await notesService.getNoteDtoByIdOrAlias('test4')).content,
|
(await notesService.getNoteDtoByIdOrAlias('test4')).content,
|
||||||
).toEqual('New note text');
|
).toEqual('New note text');
|
||||||
|
expect(response.body.content).toEqual('New note text');
|
||||||
|
|
||||||
// check if a missing note correctly returns 404
|
// check if a missing note correctly returns 404
|
||||||
await request(app.getHttpServer())
|
await request(app.getHttpServer())
|
||||||
|
|
Loading…
Reference in a new issue