Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ public Set<PulseResponse> findByFields(UUID teamMemberId, LocalDate dateFrom, Lo
// The current user can view the pulse response if they are the team member who submitted the pulse response
// or if they are the supervisor of the team member who submitted the pulse response
private boolean canViewDueToReportingHierarchy(PulseResponse pulse, UUID currentUserId) {
return pulse.getTeamMemberId().equals(currentUserId) ||
isSubordinateTo(pulse.getTeamMemberId(), currentUserId);
UUID id = pulse.getTeamMemberId();
return id != null &&
(id.equals(currentUserId) || isSubordinateTo(id, currentUserId));
}

private boolean isSubordinateTo(UUID reportMember, UUID currentUserId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ default PulseResponse createADefaultPulseResponse(MemberProfile memberprofile) {
return getPulseResponseRepository().save(new PulseResponse(0, 0, LocalDate.now(),
memberprofile.getId(), "internalfeelings", "externalfeelings"));
}

default PulseResponse createADefaultAnonymousPulseResponse() {
return getPulseResponseRepository().save(new PulseResponse(0, 0, LocalDate.now(),
null, "internalfeelings", "externalfeelings"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,22 @@ void testGetFindByfindBySubmissionDateBetween() {
assertEquals(Set.of(pulseResponse), response.body());
}

@Test
void testAnonymousGetFindByfindBySubmissionDateBetween() {
MemberProfile memberProfile = createADefaultMemberProfile();

PulseResponse pulseResponse = createADefaultAnonymousPulseResponse();

LocalDate testDateFrom = LocalDate.of(2019, 1, 1);
LocalDate testDateTo = Util.MAX.toLocalDate();

final HttpRequest<?> request = HttpRequest.GET(String.format("/?dateFrom=%tF&dateTo=%tF", testDateFrom, testDateTo)).basicAuth(memberProfile.getWorkEmail(), ADMIN_ROLE);
final HttpResponse<Set<PulseResponse>> response = client.toBlocking().exchange(request, Argument.setOf(PulseResponse.class));

assertEquals(HttpStatus.OK, response.getStatus());
assertEquals(Set.of(pulseResponse), response.body());
}

@Test
void testGetFindById() {

Expand Down
Loading