fix: veralteten stand vor weiteren prüfungen als konflikt melden
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ff2860f7be
commit
9ba4655662
2 files changed
+16
No files matched your search
@@ -125,6 +125,9 @@ def update_clip(
|
||||
expected_version: int | None = None,
|
||||
) -> Clip:
|
||||
"""Apply a partial update. With expected_version, a concurrent change raises ClipConflict."""
|
||||
# Early check so a stale client gets the conflict, not a follow-up validation error
|
||||
if expected_version is not None and clip.version != expected_version:
|
||||
raise ClipConflict(clip)
|
||||
kind = changes.get("kind", clip.kind)
|
||||
title = changes.get("title", clip.title)
|
||||
content = changes.get("content", clip.content)
|
||||
|
||||
@@ -141,6 +141,19 @@ def test_delete_project_keeps_clips(anna):
|
||||
assert current["updated_at"] == clip["updated_at"]
|
||||
|
||||
|
||||
def test_stale_editor_gets_conflict_after_project_deletion(anna):
|
||||
project = create_project(anna)
|
||||
clip = create_clip(anna, project_id=project["id"])
|
||||
anna.delete(f"/api/projects/{project['id']}")
|
||||
|
||||
response = anna.patch(
|
||||
f"/api/clips/{clip['id']}",
|
||||
json={"content": "edit", "project_id": project["id"], "version": clip["version"]},
|
||||
)
|
||||
assert response.status_code == 409
|
||||
assert response.json()["current"]["project_id"] is None
|
||||
|
||||
|
||||
def test_requires_login(client):
|
||||
assert client.get("/api/projects").status_code == 401
|
||||
|
||||
|
||||
Reference in new issue
Block a user