Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
change post timesheet entry endpoint to take an array of entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Miika Hyttinen committed Oct 19, 2022
1 parent c21c66b commit 4e0ea11
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,8 @@ class TimesheetEntryController(private val timesheetEntryService: TimesheetEntry
response.writer.print(csvString)
}

@PreAuthorize("hasAuthority('ADMIN') or #timesheetEntry.timesheet.employee.email == authentication.principal.getClaim(\"email\")")
@PostMapping(value = ["/timesheet-entry"], consumes = [APPLICATION_JSON_VALUE], produces = [APPLICATION_JSON_VALUE])
fun createTimesheetEntry(@Valid @RequestBody timesheetEntry: TimesheetEntryDTO) =
timesheetEntryService.createTimesheetEntry(timesheetEntry)

@PreAuthorize("hasAuthority('ADMIN') or #timesheetEntryService.hasValidEmails(timesheetEntries, authentication.principal.getClaim(\"email\"))")
@PostMapping(value = ["/timesheet-entries"], consumes = [APPLICATION_JSON_VALUE], produces = [APPLICATION_JSON_VALUE])
@PostMapping(value = ["/timesheet-entry"], consumes = [APPLICATION_JSON_VALUE], produces = [APPLICATION_JSON_VALUE])
fun createTimesheetEntries(@Valid @RequestBody timesheetEntries: List<TimesheetEntryDTO>) =
timesheetEntryService.createTimesheetEntries(timesheetEntries)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ class TimesheetEntryControllerIntegrationTest : ControllerIntegrationTest() {
assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
}

@Test
fun `add timesheetEntry returns 200`() {
val httpEntity = jsonPostEntity("timesheetEntry/validCreation.json")
val response = restTemplate.postForEntity("/timesheet-entry", httpEntity, ObjectNode::class.java)
assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
}
@Test
fun `add timesheetEntries returns 200`() {
val httpEntity = jsonPostEntity("timesheetEntry/validCreateMany.json")
val response = restTemplate.postForEntity("/timesheet-entries", httpEntity, ArrayNode::class.java)
val response = restTemplate.postForEntity("/timesheet-entry", httpEntity, ArrayNode::class.java)
assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
}

Expand Down
70 changes: 0 additions & 70 deletions src/test/resources/timesheetEntry/validCreation.json

This file was deleted.

0 comments on commit 4e0ea11

Please sign in to comment.