Skip to content

Commit

Permalink
Fix casing issue in member group service/repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan committed Oct 1, 2018
1 parent 328b4b1 commit eda6e08
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public void AssignRolesInternal(int[] memberIds, string[] roleNames)
var nonAssignedRoles = roleNames.Except(assignedRoles, StringComparer.CurrentCultureIgnoreCase);
foreach (var toAssign in nonAssignedRoles)
{
var groupId = rolesForNames.First(x => x.Text == toAssign).NodeId;
var groupId = rolesForNames.First(x => x.Text.InvariantEquals(toAssign)).NodeId;
Database.Insert(new Member2MemberGroupDto { Member = mId, MemberGroup = groupId });
}
}
Expand Down
25 changes: 24 additions & 1 deletion src/Umbraco.Tests/Services/MemberServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,29 @@ public void Associate_Members_To_Roles_With_Member_Id()
Assert.AreEqual(2, membersInRole.Count());
}

[Test]
public void Associate_Members_To_Roles_With_Member_Id_Casing()
{
ServiceContext.MemberService.AddRole("MyTestRole1");

IMemberType memberType = MockedContentTypes.CreateSimpleMemberType();
ServiceContext.MemberTypeService.Save(memberType);
var member1 = MockedMember.CreateSimpleMember(memberType, "test1", "[email protected]", "pass", "test1");
ServiceContext.MemberService.Save(member1);
var member2 = MockedMember.CreateSimpleMember(memberType, "test2", "[email protected]", "pass", "test2");
ServiceContext.MemberService.Save(member2);

// temp make sure they exist
Assert.IsNotNull(ServiceContext.MemberService.GetById(member1.Id));
Assert.IsNotNull(ServiceContext.MemberService.GetById(member2.Id));

ServiceContext.MemberService.AssignRoles(new[] { member1.Id, member2.Id }, new[] { "mytestrole1" });

var membersInRole = ServiceContext.MemberService.GetMembersInRole("MyTestRole1");

Assert.AreEqual(2, membersInRole.Count());
}

[Test]
public void Associate_Members_To_Roles_With_Member_Username()
{
Expand Down Expand Up @@ -1179,4 +1202,4 @@ public void Ensure_Content_Xml_Created()
}

}
}
}

0 comments on commit eda6e08

Please sign in to comment.