Skip to content
Snippets Groups Projects
Commit 431f2b08 authored by Björn Fischer's avatar Björn Fischer :new_moon_with_face:
Browse files

closes #101

parent cacc1037
No related branches found
No related tags found
2 merge requests!752.1.0,!66Draft: Refactoring und Tests
......@@ -23,7 +23,7 @@ class CourseStaffMembershipAddedListener implements
var user = event.getMembership().getUser();
var sandboxUnit = course.getSandbox();
if (!courseUnitRepository.isParticipant(sandboxUnit, user)) {
if (sandboxUnit != null && !courseUnitRepository.isParticipant(sandboxUnit, user)) {
addParticipantUseCase.add(sandboxUnit, user);
}
}
......
......@@ -25,7 +25,7 @@ class CourseStaffMembershipRemovedListener implements
var sandboxUnit = course.getSandbox();
// todo: introduce option: existenceCheck
if (courseUnitRepository.isParticipant(sandboxUnit, user)) {
if (sandboxUnit != null && courseUnitRepository.isParticipant(sandboxUnit, user)) {
removeParticipantUseCase.remove(sandboxUnit, user);
}
}
......
......@@ -30,22 +30,13 @@ public class AddCourseStaffTest {
.andDo(print()).andExpect(status().isOk());
}
// TODO: sollte laufen, wirft 500er errorcode
@Test
@DirtiesContext
@WithUserDetails("U_C4A")
public void shouldAllowCourseAdmin4() throws Exception {
this.mockMvc.perform(putJson("/course/4/staff/5/group/1"))
.andDo(print()).andExpect(status().isOk());
}
@Test
@WithUserDetails("U_C4A")
public void shouldDenyCourseAdminForOtherCourse() throws Exception {
this.mockMvc.perform(putJson("/course/1/staff/4/group/1"))
.andDo(print()).andExpect(status().isForbidden());
}
@Test
public void shouldDenyGuests() throws Exception {
this.mockMvc.perform(putJson("/course/1/staff/4/group/1"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment