From a62ec84bc5a2e846bb1c52df7e49c5e39104787a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20W=C3=B6rndle?= Date: Mon, 30 Jan 2023 13:25:59 +0100 Subject: [PATCH] fix: edit desk types error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Pfahler Signed-off-by: Philipp Wörndle --- src/deskstar-backend/Deskstar/Usecases/ResourceUsecases.cs | 2 +- .../Teststar.Tests/Tests/ResourceUsecaseTests.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/deskstar-backend/Deskstar/Usecases/ResourceUsecases.cs b/src/deskstar-backend/Deskstar/Usecases/ResourceUsecases.cs index d4124a02..b0cac09e 100644 --- a/src/deskstar-backend/Deskstar/Usecases/ResourceUsecases.cs +++ b/src/deskstar-backend/Deskstar/Usecases/ResourceUsecases.cs @@ -232,7 +232,7 @@ public DeskType UpdateDeskType(Guid companyId, Guid deskTypeId, string? deskType throw new EntityNotFoundException($"There is no desk type with id '{deskTypeId}'"); if (deskTypeExists.CompanyId != companyId) - throw new InsufficientPermissionException($"'{companyId}' has no access to administrate desk type '{deskTypeId}'"); + throw new InsufficientPermissionException($"Your company has no access to administrate desk type '{deskTypeExists.DeskTypeName}'"); //change deskTypeName if (deskTypeName != null) diff --git a/src/deskstar-backend/Teststar.Tests/Tests/ResourceUsecaseTests.cs b/src/deskstar-backend/Teststar.Tests/Tests/ResourceUsecaseTests.cs index deb4173d..b6f6b892 100644 --- a/src/deskstar-backend/Teststar.Tests/Tests/ResourceUsecaseTests.cs +++ b/src/deskstar-backend/Teststar.Tests/Tests/ResourceUsecaseTests.cs @@ -2088,7 +2088,8 @@ public void UpdateDeskType_WhenDeskTypeDoesBelongToDifferentCompany_ShouldThrowI var companyId = Guid.NewGuid(); var deskTypeId = Guid.NewGuid(); - var deskType = new DeskType { CompanyId = companyId, DeskTypeId = deskTypeId, DeskTypeName = "testdesktype" }; + var deskTypeName = "testdesktype"; + var deskType = new DeskType { CompanyId = companyId, DeskTypeId = deskTypeId, DeskTypeName = deskTypeName }; context.DeskTypes.Add(deskType); context.SaveChanges(); @@ -2103,7 +2104,7 @@ public void UpdateDeskType_WhenDeskTypeDoesBelongToDifferentCompany_ShouldThrowI // act+assert var ex = Assert.Throws(() => resourceUsecases.UpdateDeskType(noPermissionCompanyId, deskTypeId, null)); Assert.NotNull(ex); - Assert.That(ex.Message, Is.EqualTo($"'{noPermissionCompanyId}' has no access to administrate desk type '{deskTypeId}'")); + Assert.That(ex.Message, Is.EqualTo($"Your company has no access to administrate desk type '{deskTypeName}'")); // cleanup context.Database.EnsureDeleted();