-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,42 @@ class ProcedureCtrlTest extends PlaySpecification with TestAppBuilder { | |
) | ||
} | ||
|
||
// TODO test update of fields | ||
// description | ||
"update a procedure" in testApp { app => | ||
val request1 = FakeRequest("POST", "/api/v1/procedure/testProcedure3") | ||
.withJsonBody( | ||
Json.toJson( | ||
InputProcedure( | ||
"an old description", | ||
new Date(), | ||
"1", | ||
"T123" | ||
) | ||
) | ||
) | ||
.withHeaders("user" -> "[email protected]") | ||
val result1 = app[ProcedureCtrl].create(request1) | ||
val procedureId = contentAsJson(result1).as[OutputProcedure]._id | ||
status(result1) must beEqualTo(201).updateMessage(s => s"$s\n${contentAsString(result1)}") | ||
|
||
val updatedDate = new Date() | ||
val request2 = FakeRequest("PATCH", "/api/v1/procedure/testProcedure3") | ||
.withHeaders("user" -> "[email protected]") | ||
.withJsonBody(Json.obj("description" -> "a new description", "occurence" -> updatedDate)) | ||
val result2 = app[ProcedureCtrl].update(procedureId)(request2) | ||
status(result2) must beEqualTo(204).updateMessage(s => s"$s\n${contentAsString(result2)}") | ||
|
||
val request3 = FakeRequest("GET", "/api/v1/procedure/testProcedure3") | ||
.withHeaders("user" -> "[email protected]") | ||
val result3 = app[ProcedureCtrl].get(procedureId)(request3) | ||
status(result3) must beEqualTo(200).updateMessage(s => s"$s\n${contentAsString(result3)}") | ||
|
||
val resultProcedure = contentAsJson(result3).as[OutputProcedure] | ||
TestProcedure(resultProcedure) must_=== TestProcedure( | ||
"a new description", | ||
updatedDate, | ||
"T123" | ||
) | ||
} | ||
|
||
"delete a procedure" in testApp { app => | ||
val request1 = FakeRequest("POST", "/api/v1/procedure/testProcedure3") | ||
|