diff --git a/src/main/kotlin/fr/dcproject/repository/Comment.kt b/src/main/kotlin/fr/dcproject/repository/Comment.kt index 5ccc54b..d4ef39a 100644 --- a/src/main/kotlin/fr/dcproject/repository/Comment.kt +++ b/src/main/kotlin/fr/dcproject/repository/Comment.kt @@ -94,7 +94,7 @@ open class Comment (override var requester: Requester): Repositor .getFunction("edit_comment") .sendQuery( "reference" to reference, - "id" to comment.target.id, + "id" to comment.id, "content" to comment.content ) } diff --git a/src/main/kotlin/fr/dcproject/routes/Comment.kt b/src/main/kotlin/fr/dcproject/routes/Comment.kt index 1ea9324..c98bfb0 100644 --- a/src/main/kotlin/fr/dcproject/routes/Comment.kt +++ b/src/main/kotlin/fr/dcproject/routes/Comment.kt @@ -38,7 +38,7 @@ fun Route.comment(repo: CommentRepository) { assertCan(UPDATE,comment) comment.content = call.receiveText() - repo.edit(comment as fr.dcproject.entity.Comment) + repo.edit(comment as CommentEntity) call.respond(HttpStatusCode.OK, comment) } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index c1e61e6..39f7709 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -9,5 +9,6 @@ + diff --git a/src/test/resources/feature/comment.feature b/src/test/resources/feature/comment.feature index 3f00adb..ab47dfd 100644 --- a/src/test/resources/feature/comment.feature +++ b/src/test/resources/feature/comment.feature @@ -26,7 +26,12 @@ Feature: comment Article and Constitution Hello boy """ Then the response status code should be 200 - # TODO check if data is realy edited + And the JSON should contain: + | content | Hello boy | + + Scenario: The route for get comment must response a 200 and return object + When I send a GET request to "/comments/2f01c257-cf20-3466-fb10-a3b8eff12a97" + Then the response status code should be 200 And the JSON should contain: | content | Hello boy | diff --git a/src/test/sql/comment.sql b/src/test/sql/comment.sql index b42749f..9106390 100644 --- a/src/test/sql/comment.sql +++ b/src/test/sql/comment.sql @@ -54,15 +54,16 @@ begin created_by_id => _citizen_id, content => 'Ho my god !'::text ) into _comment_id; - assert (select count(*) = 1 from "comment"), 'comment must be inserted'; + assert (select count(*) = 1 from "comment"), 'comment must be inserted, "' || (select count(*) from "comment") || '" exist'; + assert (select com.content = 'Ho my god !' from "comment" com), 'the content of comment must be "Ho my god !" instead of "' || (select com.content from "comment" as com) || '"'; select find_comment_by_id(_comment_id) into _find_comments_by_id_result; assert (_find_comments_by_id_result->>'content' = 'Ho my god !'), 'content of comment must be "Ho my god !"'; perform edit_comment( reference => 'article'::regclass, - id => _comment_id, - content => 'edited content'::text + _id => _comment_id, + _content => 'edited content'::text ); assert (select count(*) = 1 from "comment"), 'edit comment must not insert new comment'; assert (select count(*) = 1 from "comment" where content = 'edited content'), 'edit comment must not insert new comment'; @@ -102,7 +103,7 @@ begin content => 'are you really sure ?'::text, parent_id => _comment_id_response::uuid ) into _comment_id_response2; - assert (select count(*) = 3 from "comment"), 'comment must be inserted'; + assert (select count(*) = 3 from "comment"), 'response must be inserted'; assert (select com.parents_ids @> ARRAY[_comment_id] from "comment" com where id = _comment_id_response), 'parents_ids not contain "' || _comment_id::text || '" ' || (select com.parents_ids::text[] from "comment" com where id = _comment_id_response); assert (select com.parents_ids @> ARRAY[_comment_id_response] from "comment" com where id = _comment_id_response2), 'parents_ids not contain "' || _comment_id_response::text || '" ' || (select com.parents_ids::text[] from "comment" com where id = _comment_id_response2); assert (select com.parents_ids @> ARRAY[_comment_id] from "comment" com where id = _comment_id_response2), 'parents_ids not contain "' || _comment_id::text || '" ' || (select com.parents_ids::text[] from "comment" com where id = _comment_id_response2);