diff --git a/nio-server/app/models/ConsentFact.scala b/nio-server/app/models/ConsentFact.scala index 2507ed3..4b01319 100644 --- a/nio-server/app/models/ConsentFact.scala +++ b/nio-server/app/models/ConsentFact.scala @@ -313,7 +313,7 @@ case class PartialConsentFact( userId: Option[String] = None, doneBy: Option[DoneBy] = None, version: Option[Int] = None, - lastUpdate: Option[LocalDateTime] = None, + lastUpdate: Option[LocalDateTime] = Some(LocalDateTime.now(Clock.systemUTC)), groups: Option[Seq[PartialConsentGroup]] = None, offers: Option[Seq[PartialConsentOffer]] = None, orgKey: Option[String] = None, @@ -325,7 +325,7 @@ case class PartialConsentFact( userId = userId.getOrElse(lastConsentFact.userId), doneBy = doneBy.getOrElse(lastConsentFact.doneBy), version = version.getOrElse(organisation.version.num), - lastUpdate = lastUpdate.getOrElse(lastConsentFact.lastUpdate), + lastUpdate = lastUpdate.getOrElse(LocalDateTime.now(Clock.systemUTC)), lastUpdateSystem = LocalDateTime.now(Clock.systemUTC), groups = groups.map(g => PartialConsentGroup.merge(g, lastConsentFact.groups, organisation.groups)).getOrElse(lastConsentFact.groups), offers = offers.map(o => PartialConsentOffer.merge(o, lastConsentFact.offers)).getOrElse(lastConsentFact.offers), diff --git a/nio-server/test/controllers/ConsentControllerSpec.scala b/nio-server/test/controllers/ConsentControllerSpec.scala index 36aa31c..b9efe5e 100644 --- a/nio-server/test/controllers/ConsentControllerSpec.scala +++ b/nio-server/test/controllers/ConsentControllerSpec.scala @@ -818,10 +818,13 @@ class ConsentControllerSpec extends TestUtils { "Partial update on consent" in { val organisationKey: String = "maif" - val path: String = - s"/$tenant/organisations/$organisationKey/users/$userId1" - val putResponse = putJson(path, user1AsJson) + val userId = userId1 + "1" + val user = user1.copy(userId = userId) + + val path: String = s"/$tenant/organisations/$organisationKey/users/$userId" + val putResponse = putJson(path, user.asJson()) + println(putResponse.json) putResponse.status mustBe OK val patchResponse = patchJson(path, Json.obj( @@ -840,7 +843,7 @@ class ConsentControllerSpec extends TestUtils { patchResponse.status mustBe OK val expectedDate: LocalDateTime = (json \ "lastUpdate").validate(DateUtils.utcDateTimeReads).get - json mustBe user1.copy( + json mustBe user.copy( orgKey = Some("maif"), lastUpdate = expectedDate, groups = user1.groups.updated(0, user1.groups(0).copy(