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

change post timesheet entry endpoint to take an array of entries #137

Merged
merged 1 commit into from
Oct 24, 2022
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 @@ -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.