feature #7: check if comment content is realy edited

add somes tests
This commit is contained in:
2019-08-27 23:18:42 +02:00
parent 1fb0e39038
commit b5cb238061
5 changed files with 14 additions and 7 deletions

View File

@@ -94,7 +94,7 @@ open class Comment <T: UuidEntity>(override var requester: Requester): Repositor
.getFunction("edit_comment") .getFunction("edit_comment")
.sendQuery( .sendQuery(
"reference" to reference, "reference" to reference,
"id" to comment.target.id, "id" to comment.id,
"content" to comment.content "content" to comment.content
) )
} }

View File

@@ -38,7 +38,7 @@ fun Route.comment(repo: CommentRepository) {
assertCan(UPDATE,comment) assertCan(UPDATE,comment)
comment.content = call.receiveText() comment.content = call.receiveText()
repo.edit(comment as fr.dcproject.entity.Comment<UuidEntity>) repo.edit(comment as CommentEntity<UuidEntity>)
call.respond(HttpStatusCode.OK, comment) call.respond(HttpStatusCode.OK, comment)
} }

View File

@@ -9,5 +9,6 @@
</root> </root>
<logger name="org.eclipse.jetty" level="INFO"/> <logger name="org.eclipse.jetty" level="INFO"/>
<logger name="com.github.jasync" level="WARN"/> <logger name="com.github.jasync" level="WARN"/>
<logger name="fr.postgresjson" level="debug"/>
<logger name="io.netty" level="INFO"/> <logger name="io.netty" level="INFO"/>
</configuration> </configuration>

View File

@@ -26,7 +26,12 @@ Feature: comment Article and Constitution
Hello boy Hello boy
""" """
Then the response status code should be 200 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: And the JSON should contain:
| content | Hello boy | | content | Hello boy |

View File

@@ -54,15 +54,16 @@ begin
created_by_id => _citizen_id, created_by_id => _citizen_id,
content => 'Ho my god !'::text content => 'Ho my god !'::text
) into _comment_id; ) 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; 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 !"'; assert (_find_comments_by_id_result->>'content' = 'Ho my god !'), 'content of comment must be "Ho my god !"';
perform edit_comment( perform edit_comment(
reference => 'article'::regclass, reference => 'article'::regclass,
id => _comment_id, _id => _comment_id,
content => 'edited content'::text _content => 'edited content'::text
); );
assert (select count(*) = 1 from "comment"), 'edit comment must not insert new comment'; 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'; 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, content => 'are you really sure ?'::text,
parent_id => _comment_id_response::uuid parent_id => _comment_id_response::uuid
) into _comment_id_response2; ) 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] 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_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); 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);