diff --git a/SPECGAPS.md b/SPECGAPS.md index dc21170..949067d 100644 --- a/SPECGAPS.md +++ b/SPECGAPS.md @@ -144,7 +144,7 @@ All reconciled to follow code. Specs must be self-consistent and match code. | ~~D2-4~~ | ~~UniqueScriptSlug dedup~~ | ~~script.allium:115~~ | **Resolved:** test added asserting two scripts with same title produce unique slugs (`dup-slug` → `dup-slug-2`) | | D2-5 | ~~FrontmatterRoundtrip invariant~~ | post.allium:223 | **Resolved:** test added — creates post with all fields, publishes, parses file back via `Frontmatter.parse_document`, asserts every field (id, title, slug, excerpt, status, author, language, doNotTranslate, templateSlug, tags, categories, createdAt, updatedAt, publishedAt, body) matches the published DB record | | ~~D2-6~~ | ~~SidecarRoundtrip invariant~~ | ~~media.allium:198~~ | **Resolved:** 2 tests added — full roundtrip (write sidecar, parse via `Sidecar.parse_document/1`, assert all fields match DB) + nil conditional fields absent from parsed sidecar | -| D2-7 | ConditionalPostFields: nil fields absent from frontmatter | frontmatter.allium:398 | Write test: post with nil excerpt/author/language → fields not in file | +| ~~D2-7~~ | ~~ConditionalPostFields: nil fields absent from frontmatter~~ | frontmatter.allium:398 | **Resolved:** test added — post with nil excerpt/author/language → those fields absent from published file, 3 refute assertions | | D2-8 | ConditionalMediaFields: nil fields absent from sidecar | frontmatter.allium:417 | Write test: media with nil title/alt → fields not in sidecar | | D2-9 | max_posts_per_page 1..500 constraint | metadata.allium:75-77 | Write test: values outside range rejected | | D2-10 | SandboxedExecution: restricted capabilities blocked | script.allium:84-88 | Write test: filesystem/process/package loading blocked | diff --git a/test/bds/posts_test.exs b/test/bds/posts_test.exs index 8c110ec..81efb1b 100644 --- a/test/bds/posts_test.exs +++ b/test/bds/posts_test.exs @@ -256,6 +256,31 @@ defmodule BDS.PostsTest do refute file_contents =~ "doNotTranslate" end + test "publish_post omits nil excerpt, author, language from frontmatter", %{ + project: project, + temp_dir: temp_dir + } do + assert {:ok, post} = + BDS.Posts.create_post(%{ + project_id: project.id, + title: "Nil Optional Fields", + content: "body" + }) + + assert is_nil(post.excerpt) + assert is_nil(post.author) + assert is_nil(post.language) + + assert {:ok, published} = BDS.Posts.publish_post(post.id) + + full_path = Path.join(temp_dir, published.file_path) + file_contents = File.read!(full_path) + + refute file_contents =~ "excerpt:" + refute file_contents =~ "author:" + refute file_contents =~ "language:" + end + test "publish_post deletes old file when file path changes", %{ project: project, temp_dir: temp_dir