Skip to content

Commit ed30402

Browse files
committed
Add log statement if failure to update view
1 parent d8ddc32 commit ed30402

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

draft-api/src/main/scala/no/ndla/draftapi/service/WriteService.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,14 @@ class WriteService(using
354354
} else {
355355
val responsibleIdWasUpdated = hasResponsibleBeenUpdated(draft, oldDraft)
356356
if (responsibleIdWasUpdated) {
357-
draftRepository.refreshResponsibleView: Unit
357+
draftRepository
358+
.refreshResponsibleView
359+
.recover { case ex =>
360+
logger.error(
361+
s"Failed to refresh responsible view after responsible change for article ${draft.id.getOrElse("unknown")}",
362+
ex,
363+
)
364+
}: Unit
358365
}
359366
val shouldReset = statusWasUpdated && !isAutomaticStatusChange || responsibleIdWasUpdated
360367
draft.copy(started = !shouldReset)

draft-api/src/test/scala/no/ndla/draftapi/service/WriteServiceTest.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,7 @@ class WriteServiceTest extends UnitSuite with TestEnvironment {
12781278
.copy(revision = 1, title = Some("updated title"), language = Some("nb"), responsibleId = UpdateWith("heiho"))
12791279
when(draftRepository.slugExists(any, any)(using any)).thenReturn(Success(false))
12801280
when(draftRepository.withId(eqTo(existing.id.get))(using any)).thenReturn(Success(Some(existing)))
1281+
when(draftRepository.refreshResponsibleView(using any)).thenReturn(Success(()))
12811282
val result = service.updateArticle(existing.id.get, updatedArticle, TestData.userWithWriteAccess).get
12821283

12831284
result.started should be(false)

0 commit comments

Comments
 (0)