Skip to content

Commit

Permalink
fix: edit desk types error messages
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Pfahler <[email protected]>
Signed-off-by: Philipp Wörndle <[email protected]>
  • Loading branch information
woerndle and stefanpfahler committed Jan 30, 2023
1 parent fc524f2 commit a62ec84
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/deskstar-backend/Deskstar/Usecases/ResourceUsecases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -2103,7 +2104,7 @@ public void UpdateDeskType_WhenDeskTypeDoesBelongToDifferentCompany_ShouldThrowI
// act+assert
var ex = Assert.Throws<InsufficientPermissionException>(() => 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();
Expand Down

0 comments on commit a62ec84

Please sign in to comment.