Skip to content

Commit

Permalink
Fixed issue with sprint dates validation
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonpoltorak committed May 11, 2024
1 parent 347f0a3 commit cf20f69
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ public final List<SprintResponse> getCurrentAndFutureSprints(@RequestParam long
@Override
@GetMapping(value = SPRINTS_AFTER_SPRINT)
public final Page<SprintResponse> getSprintsAfterSprint(@RequestParam long sprintId,
Pageable pageable,
@JwtAuthed User user) {
Pageable pageable,
@JwtAuthed User user) {
return sprintService.getSprintsAfterSprint(sprintId, pageable, user);
}

@Override
@GetMapping(value = SPRINTS_BEFORE_SPRINT)
public final Page<SprintResponse> getSprintsBeforeSprint(@RequestParam long sprintId,
Pageable pageable,
@JwtAuthed User user) {
Pageable pageable,
@JwtAuthed User user) {
return sprintService.getSprintsBeforeSprint(sprintId, pageable, user);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public SprintResponse updateSprintsDescription(String description, long sprintId
public SprintResponse updateSprintsStartDate(LocalDate startDate, long sprintId, User user) {
log.info("Updating sprint with id: {} startDate to: {}", sprintId, startDate);

if (sprintRepository.existsSprintPeriodWithGivenDate(startDate)) {
if (sprintRepository.existsSprintPeriodWithGivenDate(startDate, sprintId)) {
throw new InvalidSprintDateException("Start date cannot be after any existing sprint's end date");
}
Sprint sprintToUpdate = sprintRepository.findByIdWithProjectOwner(sprintId, user)
Expand All @@ -163,7 +163,7 @@ public SprintResponse updateSprintsStartDate(LocalDate startDate, long sprintId,
public SprintResponse updateSprintsEndDate(LocalDate endDate, long sprintId, User user) {
log.info("Updating sprint with id: {} endDate to: {}", sprintId, endDate);

if (sprintRepository.existsSprintPeriodWithGivenDate(endDate)) {
if (sprintRepository.existsSprintPeriodWithGivenDate(endDate, sprintId)) {
throw new InvalidSprintDateException("End date cannot be before any existing sprint's end date");
}
Sprint sprintToUpdate = sprintRepository.findByIdWithProjectOwner(sprintId, user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ select count(s) > 0 from Sprint s
*/
@Query("""
select count(*) > 0 from Sprint s
where s.endDate <= :date and s.startDate >= :date
where s.endDate <= :date and s.startDate >= :date and s.sprintId != :sprintId
""")
boolean existsSprintPeriodWithGivenDate(LocalDate date);
boolean existsSprintPeriodWithGivenDate(LocalDate date, long sprintId);

/**
* Finds all sprints with given project that have end date after specified date and pages them
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ final void test_updateSprintsStartDate_shouldThrowInvalidSprintDateException() {
User owner = ADD_SPRINT_DATA.project().getOwner();

// when
when(sprintRepository.existsSprintPeriodWithGivenDate(newStartDate))
when(sprintRepository.existsSprintPeriodWithGivenDate(newStartDate, sprintId))
.thenReturn(true);

// then
Expand Down

0 comments on commit cf20f69

Please sign in to comment.