Fix #3612 Team Patch API is not updating isJoinable field (#3628)

This commit is contained in:
Vivek Ratnavel Subramanian 2022-03-23 17:57:01 -07:00 committed by GitHub
parent ac93a3a7ce
commit 6c9174b9d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -274,6 +274,7 @@ public class TeamRepository extends EntityRepository<Team> {
@Override
public void entitySpecificUpdate() throws IOException {
recordChange("profile", original.getEntity().getProfile(), updated.getEntity().getProfile());
recordChange("isJoinable", original.getEntity().getIsJoinable(), updated.getEntity().getIsJoinable());
updateUsers(original.getEntity(), updated.getEntity());
updateDefaultRoles(original.getEntity(), updated.getEntity());
}

View File

@ -256,6 +256,29 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
ADMIN_AUTH_HEADERS);
}
@Test
void patch_isJoinable_200(TestInfo test) throws IOException {
CreateTeam create =
createRequest(getEntityName(test), "description", "displayName", null)
.withProfile(PROFILE)
.withIsJoinable(false);
Team team = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
// patch the team with isJoinable set to true
String json = JsonUtils.pojoToJson(team);
team.setIsJoinable(true);
ChangeDescription change = getChangeDescription(team.getVersion());
change.getFieldsUpdated().add(new FieldChange().withName("isJoinable").withOldValue(false).withNewValue(true));
team = patchEntityAndCheck(team, json, ADMIN_AUTH_HEADERS, UpdateType.MINOR_UPDATE, change);
// set isJoinable to false and check
json = JsonUtils.pojoToJson(team);
team.setIsJoinable(false);
change = getChangeDescription(team.getVersion());
change.getFieldsUpdated().add(new FieldChange().withName("isJoinable").withOldValue(true).withNewValue(false));
patchEntityAndCheck(team, json, ADMIN_AUTH_HEADERS, UpdateType.MINOR_UPDATE, change);
}
@Test
void patch_deleteUserAndDefaultRoleFromTeam_200(TestInfo test) throws IOException {
UserResourceTest userResourceTest = new UserResourceTest();