Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug on last update #197

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nio-server/app/models/ConsentFact.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down
11 changes: 7 additions & 4 deletions nio-server/test/controllers/ConsentControllerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
Loading