PATCH and DELETE /journal/:id were never registered. Both handlers existed, were covered by service-level tests, and were completely unreachable — my edit to the router anchored on a string that only exists on another branch, so it silently did nothing. Registered, and covered by an API-level test that walks the whole lifecycle through the router, because that is the only kind of test that could have caught it. Anything addressed by its own id now has one. An entry about a plop was invisible under its bed's filter. Naming only a planting left object_id null, so "notes about this bed" silently excluded every note written about something growing IN the bed — the two filters disagreed about what an entry is about, which is precisely the question the reader is asking. The parent object is now derived from the planting. checkJournalTarget flattened every store error to ErrInvalidInput, so a real database failure surfaced as a 400 telling the caller their request was bad, and never reached the logs. Only "no such row" is a bad reference now; anything else passes through. ListJournalEntries repeated the column scan order inline, one column different from scanJournalEntry — the classic way for a shared column list to drift out of step with its readers. Both now build from journalScanTargets, with the list appending the joined author name. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01H3zbym8Doka2d7D48maSgZ
This commit is contained in:
@@ -292,3 +292,34 @@ func TestJournalStaysOutOfRevisionHistory(t *testing.T) {
|
||||
t.Errorf("journal writes produced %d change sets; they should produce none", got-before)
|
||||
}
|
||||
}
|
||||
|
||||
// TestPlopEntryIsVisibleUnderItsBed — an entry about a plant IN a bed is an entry
|
||||
// about that bed. Without deriving the parent object, "notes about this bed"
|
||||
// would silently exclude every note written about something growing in it.
|
||||
func TestPlopEntryIsVisibleUnderItsBed(t *testing.T) {
|
||||
s := newTestService(t, openConfig())
|
||||
owner := seedUser(t, s, "[email protected]")
|
||||
g := seedGarden(t, s, owner)
|
||||
bed := seedBed(t, s, owner, g.ID)
|
||||
plant := seedOwnPlant(t, s, owner, 15)
|
||||
ctx := context.Background()
|
||||
|
||||
plop, err := s.CreatePlanting(ctx, owner, bed.ID, PlantingInput{
|
||||
PlantID: plant.ID, XCM: 0, YCM: 0, RadiusCM: 20,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreatePlanting: %v", err)
|
||||
}
|
||||
|
||||
// Only the plop is named — no objectId.
|
||||
e := writeEntry(t, s, owner, g.ID, JournalInput{PlantingID: &plop.ID, Body: "Scapes forming"})
|
||||
if e.ObjectID == nil || *e.ObjectID != bed.ID {
|
||||
t.Fatalf("objectId = %v, want the plop's parent bed %d", e.ObjectID, bed.ID)
|
||||
}
|
||||
if byBed := listJournal(t, s, owner, g.ID, JournalQuery{ObjectID: &bed.ID}); len(byBed) != 1 {
|
||||
t.Errorf("the bed filter found %d entries, want the plop's", len(byBed))
|
||||
}
|
||||
if byPlop := listJournal(t, s, owner, g.ID, JournalQuery{PlantingID: &plop.ID}); len(byPlop) != 1 {
|
||||
t.Errorf("the plop filter found %d entries, want 1", len(byPlop))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user