diff --git a/draft-api/src/main/scala/no/ndla/draftapi/integration/ArticleApiClient.scala b/draft-api/src/main/scala/no/ndla/draftapi/integration/ArticleApiClient.scala index 016b6adff3..e15f5a12e3 100644 --- a/draft-api/src/main/scala/no/ndla/draftapi/integration/ArticleApiClient.scala +++ b/draft-api/src/main/scala/no/ndla/draftapi/integration/ArticleApiClient.scala @@ -66,7 +66,7 @@ trait ArticleApiClient { ): Try[Draft] = { converterService .toArticleApiArticle(draft) - .map(article => + .flatMap(article => postWithData[common.article.Article, common.article.Article]( s"$InternalEndpoint/article/$id", article, diff --git a/integration-tests/src/test/scala/no/ndla/integrationtests/draftapi/articleapi/ArticleApiClientTest.scala b/integration-tests/src/test/scala/no/ndla/integrationtests/draftapi/articleapi/ArticleApiClientTest.scala index 2bcdcecd54..a09553f404 100644 --- a/integration-tests/src/test/scala/no/ndla/integrationtests/draftapi/articleapi/ArticleApiClientTest.scala +++ b/integration-tests/src/test/scala/no/ndla/integrationtests/draftapi/articleapi/ArticleApiClientTest.scala @@ -190,4 +190,20 @@ class ArticleApiClientTest .flatMap(article => articleApiCient.validateArticle(article, importValidate = false, None)) result.isSuccess should be(false) } + + test("that updating an article returns 400 if missing required field") { + AuthUser.setHeader(s"Bearer $exampleToken") + val articleApiCient = new ArticleApiClient(articleApiBaseUrl) + val invalidArticle = testArticle.copy(metaDescription = Seq.empty) + val result = articleApiCient.updateArticle( + id = 10, + draft = invalidArticle, + externalIds = List.empty, + useImportValidation = false, + useSoftValidation = false, + user = authUser + ) + + result.isSuccess should be(false) + } }