From 359450ad8f5ea023232d34e57311299ad8382fe2 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Fri, 16 Apr 2021 21:23:43 +0200 Subject: [PATCH] #61 Fix version date returned for the article.createdAt --- .../kotlin/fr/dcproject/component/article/database/Article.kt | 1 + .../fr/dcproject/component/article/routes/FindArticles.kt | 1 + src/main/resources/sql/functions/article/find_articles.sql | 1 + src/test/kotlin/integration/Article routes.kt | 2 ++ 4 files changed, 5 insertions(+) diff --git a/src/main/kotlin/fr/dcproject/component/article/database/Article.kt b/src/main/kotlin/fr/dcproject/component/article/database/Article.kt index 4fda505..d758c16 100644 --- a/src/main/kotlin/fr/dcproject/component/article/database/Article.kt +++ b/src/main/kotlin/fr/dcproject/component/article/database/Article.kt @@ -87,6 +87,7 @@ class ArticleForListing( ArticleRef(id), ArticleAuthI, Votable by VotableImp(), + CreatedAt by CreatedAt.Imp(), CreatedBy interface ArticleForListingI : ArticleWithTitleI, CreatedBy { diff --git a/src/main/kotlin/fr/dcproject/component/article/routes/FindArticles.kt b/src/main/kotlin/fr/dcproject/component/article/routes/FindArticles.kt index 44d930d..a0a4518 100644 --- a/src/main/kotlin/fr/dcproject/component/article/routes/FindArticles.kt +++ b/src/main/kotlin/fr/dcproject/component/article/routes/FindArticles.kt @@ -83,6 +83,7 @@ object FindArticles { object { val id = it.id val title = it.title + val createdAt = it.createdAt val createdBy: Any = it.createdBy.toOutput() val workgroup = it.workgroup?.let { object { diff --git a/src/main/resources/sql/functions/article/find_articles.sql b/src/main/resources/sql/functions/article/find_articles.sql index ece47ee..84c3b09 100644 --- a/src/main/resources/sql/functions/article/find_articles.sql +++ b/src/main/resources/sql/functions/article/find_articles.sql @@ -23,6 +23,7 @@ begin select a.id, a.title, + a.created_at, a.deleted_at, a.draft, find_citizen_by_id_with_user(a.created_by_id) as created_by, diff --git a/src/test/kotlin/integration/Article routes.kt b/src/test/kotlin/integration/Article routes.kt index 58f228a..22e6123 100644 --- a/src/test/kotlin/integration/Article routes.kt +++ b/src/test/kotlin/integration/Article routes.kt @@ -44,6 +44,7 @@ class `Article routes` : BaseTest() { `And the response should not be null`() `And the response should contain pattern`("$.result[0].createdBy.name.firstName", "firstName.+") `And the response should not contain`("$.result[1]") + `And the response should contain pattern`("$.result[0].createdAt", """[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z""") // 2021-04-16T16:39:06.890Z `And the response should contain list`("$.result", 1) } } @@ -82,6 +83,7 @@ class `Article routes` : BaseTest() { `When I send a GET request`("/articles/65cda9f3-8991-4420-8d41-1da9da72c9bb") `Then the response should be` OK and { `And the response should not be null`() `And have property`("$.id") `which contains` "65cda9f3-8991-4420-8d41-1da9da72c9bb" + `And the response should contain pattern`("$.createdAt", """[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z""") // 2021-04-16T16:39:06.890Z } } } -- 2.49.1