Slett feilmeldinger (#34)
* ✨ Backend støtter mulighet for å slette innmeldte feilmeldinger * ✨ Knapp i redigeringsverktøy for sletting av feil * 🐛 Fikset routing bug, Delete was not allowed, og feil endepunkt i frontend * ♿️ Refresher mainpage ved sletting av feil --------- Co-authored-by: Amalie Mansåker <amalie.erdal.mansaker@nav.no> Co-authored-by: Sindre Kjelsrud <sindre.kjelsrud@nav.no>
This commit is contained in:
		
							parent
							
								
									df3ce139c2
								
							
						
					
					
						commit
						900422a4e0
					
				
					 4 changed files with 46 additions and 1 deletions
				
			
		|  | @ -71,4 +71,8 @@ class FeilmeldingRepository { | |||
|             it[FeilmeldingTable.kommentar] = kommentar | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     fun slettFeilmelding(id: Int) = transaction { | ||||
|         FeilmeldingTable.deleteWhere { FeilmeldingTable.id eq id } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -28,6 +28,7 @@ fun configureRouting(): ApplicationEngine = embeddedServer(CIO, applicationEngin | |||
|             allowMethod(HttpMethod.Get) | ||||
|             allowMethod(HttpMethod.Post) | ||||
|             allowMethod(HttpMethod.Put) | ||||
|             allowMethod(HttpMethod.Delete) | ||||
|             allowNonSimpleContentTypes = true | ||||
|         } | ||||
|         install(ContentNegotiation) { | ||||
|  | @ -73,6 +74,12 @@ fun configureRouting(): ApplicationEngine = embeddedServer(CIO, applicationEngin | |||
|                 feilmeldingRepository.oppdaterKommentar(innkommendeKommentar.id, innkommendeKommentar.kommentar) | ||||
|                 call.respond(status = HttpStatusCode.Created, message = "Feilmelding oppdatert") | ||||
|             } | ||||
|             delete("api/slettfeilmelding/{id}") { | ||||
|                 val id = call.parameters["id"] | ||||
|                 checkNotNull(id) {"Id kan ikke være null"} | ||||
|                 feilmeldingRepository.slettFeilmelding(id.toInt()) | ||||
|                 call.respond(status = HttpStatusCode.Created, message = "Feilmelding slettet") | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|      | ||||
|  |  | |||
|  | @ -188,4 +188,12 @@ class FeilmeldingTest { | |||
|         val oppdatertKommentar = transaction { FeilmeldingTable.selectAll().single()[FeilmeldingTable.kommentar] } | ||||
|         assertEquals("Oppdatert kommentar", oppdatertKommentar) | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     fun `Feilmelding slettes basert på id`() { | ||||
|         feilmeldingRepository.lagre(feilmelding) | ||||
|         feilmeldingRepository.slettFeilmelding(getId()) | ||||
|         val resultat = transaction { FeilmeldingTable.selectAll().map { it }.size } | ||||
|         assertEquals(0, resultat) | ||||
|     } | ||||
| } | ||||
		Reference in a new issue
	
	 Markus A. R. Johansen
						Markus A. R. Johansen