fix(geschichte): persist GeschichteType on create — JOURNEY was silently dropped
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m25s
CI / OCR Service Tests (pull_request) Successful in 23s
CI / Backend Unit Tests (pull_request) Successful in 3m56s
CI / fail2ban Regex (pull_request) Successful in 47s
CI / Semgrep Security Scan (pull_request) Successful in 21s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m5s

GeschichteUpdateDTO lacked a `type` field, so the `type: 'JOURNEY'` sent by
JourneyCreate was discarded by Jackson and every new Geschichte was saved as
STORY. The edit page branched on type, so journeys always showed the STORY
editor with no document-adding capability.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-09 22:02:58 +02:00
parent bd5e6e6fbe
commit 44f15dd4a2
3 changed files with 33 additions and 0 deletions

View File

@@ -134,6 +134,7 @@ public class GeschichteService {
.title(dto.getTitle().trim()) .title(dto.getTitle().trim())
.body(sanitize(dto.getBody())) .body(sanitize(dto.getBody()))
.status(GeschichteStatus.DRAFT) .status(GeschichteStatus.DRAFT)
.type(dto.getType() != null ? dto.getType() : GeschichteType.STORY)
.author(currentUser()) .author(currentUser())
.persons(resolvePersons(dto.getPersonIds())) .persons(resolvePersons(dto.getPersonIds()))
.build(); .build();

View File

@@ -15,5 +15,6 @@ public class GeschichteUpdateDTO {
private String title; private String title;
private String body; private String body;
private GeschichteStatus status; private GeschichteStatus status;
private GeschichteType type;
private List<UUID> personIds; private List<UUID> personIds;
} }

View File

@@ -389,6 +389,37 @@ class GeschichteServiceTest {
.isEqualTo(ErrorCode.VALIDATION_ERROR); .isEqualTo(ErrorCode.VALIDATION_ERROR);
} }
@Test
void create_preserves_JOURNEY_type_from_dto() {
authenticateAs(writer, Permission.BLOG_WRITE);
when(userService.findByEmail(writer.getEmail())).thenReturn(writer);
when(geschichteRepository.save(any(Geschichte.class)))
.thenAnswer(inv -> inv.getArgument(0));
GeschichteUpdateDTO dto = new GeschichteUpdateDTO();
dto.setTitle("My Journey");
dto.setType(GeschichteType.JOURNEY);
Geschichte saved = geschichteService.create(dto);
assertThat(saved.getType()).isEqualTo(GeschichteType.JOURNEY);
}
@Test
void create_defaults_to_STORY_when_type_is_null() {
authenticateAs(writer, Permission.BLOG_WRITE);
when(userService.findByEmail(writer.getEmail())).thenReturn(writer);
when(geschichteRepository.save(any(Geschichte.class)))
.thenAnswer(inv -> inv.getArgument(0));
GeschichteUpdateDTO dto = new GeschichteUpdateDTO();
dto.setTitle("My Story");
Geschichte saved = geschichteService.create(dto);
assertThat(saved.getType()).isEqualTo(GeschichteType.STORY);
}
// ─── update ────────────────────────────────────────────────────────────── // ─── update ──────────────────────────────────────────────────────────────
@Test @Test