PM-14851: Blank names should be considered null (#4292)

This commit is contained in:
David Perez 2024-11-12 15:30:07 -06:00 committed by GitHub
parent 9a5aa217e6
commit e804dbd48e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -1302,7 +1302,7 @@ class AuthRepositoryImpl(
.sendVerificationEmail(
SendVerificationEmailRequestJson(
email = email,
name = name,
name = name.takeUnless { it.isBlank() },
receiveMarketingEmails = receiveMarketingEmails,
),
)

View file

@ -6111,6 +6111,29 @@ class AuthRepositoryTest {
)
}
@Test
fun `sendVerificationEmail with empty name should use null and return success`() = runTest {
coEvery {
identityService.sendVerificationEmail(
SendVerificationEmailRequestJson(
email = EMAIL,
name = null,
receiveMarketingEmails = true,
),
)
} returns EMAIL_VERIFICATION_TOKEN.asSuccess()
val result = repository.sendVerificationEmail(
email = EMAIL,
name = "",
receiveMarketingEmails = true,
)
assertEquals(
SendVerificationEmailResult.Success(EMAIL_VERIFICATION_TOKEN),
result,
)
}
@Test
fun `sendVerificationEmail failure should return error`() = runTest {
coEvery {