Skip to content

Commit

Permalink
Allow updating users with no roles (#1646)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad authored Nov 4, 2024
1 parent 24c9317 commit a60d245
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ public async Task<IActionResult> OnPost()
// Sanitize roles
var newRoles = Roles!.Where(r => UserRoles.All.Contains(r)).ToArray();

if (Roles?.Length == 0)
{
ModelState.AddModelError(nameof(Roles), "Select at least one role");
}

if (!ModelState.IsValid)
{
return this.PageWithErrors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,28 +184,6 @@ public async Task Post_NoName_RendersError()
await AssertEx.HtmlResponseHasError(response, "Name", "Enter a name");
}

[Fact]
public async Task Post_NoRolesSelected_RendersError()
{
// Arrange
var user = await TestData.CreateUser();
var newName = Faker.Name.FullName();

var request = new HttpRequestMessage(HttpMethod.Post, GetRequestPath(user.UserId))
{
Content = new FormUrlEncodedContentBuilder()
{
{ "Name", newName },
}
};

// Act
var response = await HttpClient.SendAsync(request);

// Assert
await AssertEx.HtmlResponseHasError(response, "Roles", "Select at least one role");
}

[Theory]
[InlineData(true, false, true, UserUpdatedEventChanges.Name)]
[InlineData(false, true, true, UserUpdatedEventChanges.Roles)]
Expand Down

0 comments on commit a60d245

Please sign in to comment.