test: D1-3 cover BundledDefaultTemplatesExistOutsideProjectData with no Template rows
This commit is contained in:
@@ -116,7 +116,7 @@ All reconciled to follow code. Specs must be self-consistent and match code.
|
||||
|---|---|---|---|
|
||||
| D1-1 | ~~UniqueMediaTranslation invariant~~ | media.allium:108 | **Resolved:** test added (re-upsert updates not duplicates; direct duplicate insert rejected). Test exposed a real bug — `Media.Translation` declared the migration's index name but ecto_sqlite3 derives the violated-constraint name from columns, so violations crashed instead of returning a changeset error; fixed `unique_constraint` name to `:media_translations_translation_for_language_index` |
|
||||
| D1-2 | ~~UniqueTranslationPerLanguage invariant~~ | translation.allium:94 | **Resolved:** test added (re-upsert updates not duplicates; direct duplicate insert rejected). Same bug as D1-1 — `Posts.Translation` declared the migration's index name but ecto_sqlite3 derives the violated-constraint name from columns, so duplicates crashed instead of returning a changeset error; fixed `unique_constraint` name to `:post_translations_translation_for_language_index` |
|
||||
| D1-3 | BundledDefaultTemplatesExistOutsideProjectData | template.allium:65 | Write test: render with no Template rows, bundled template found |
|
||||
| D1-3 | ~~BundledDefaultTemplatesExistOutsideProjectData~~ | template.allium:65 | **Resolved:** added 4 tests in `template_lookup_priority_test.exs` — with no Template rows for the project, `load_template_source/3` resolves bundled single-post/post-list/not-found defaults (and still resolves when the project has no `templates/` directory at all) |
|
||||
| D1-4 | UserTemplateDirectoryOverridesBundledDefaults | template.allium:75 | Write test: project template overrides bundled same-slug |
|
||||
| D1-5 | LiquidTagSubset (5 tags only) | template.allium:179 | Write test: unsupported tag raises error |
|
||||
| D1-6 | LiquidFilterSubset (4 standard + 2 custom) | template.allium:191 | Write test: unsupported filter raises error |
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
defmodule BDS.TemplateLookupPriorityTest do
|
||||
use ExUnit.Case, async: false
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
alias BDS.Rendering.TemplateSelection
|
||||
|
||||
setup do
|
||||
@@ -138,6 +140,44 @@ defmodule BDS.TemplateLookupPriorityTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "BundledDefaultTemplatesExistOutsideProjectData" do
|
||||
test "single-post bundled template resolves with no Template rows", %{project: project} do
|
||||
assert [] = BDS.Repo.all(from t in BDS.Templates.Template, where: t.project_id == ^project.id)
|
||||
|
||||
{:ok, source} = TemplateSelection.load_template_source(project.id, :post, nil)
|
||||
|
||||
assert source =~ ~s(data-template="single-post")
|
||||
end
|
||||
|
||||
test "post-list bundled template resolves with no Template rows", %{project: project} do
|
||||
assert [] = BDS.Repo.all(from t in BDS.Templates.Template, where: t.project_id == ^project.id)
|
||||
|
||||
{:ok, source} = TemplateSelection.load_template_source(project.id, :list, nil)
|
||||
|
||||
assert source =~ ~s({% if archive_context %})
|
||||
end
|
||||
|
||||
test "not-found bundled template resolves with no Template rows", %{project: project} do
|
||||
assert [] = BDS.Repo.all(from t in BDS.Templates.Template, where: t.project_id == ^project.id)
|
||||
|
||||
{:ok, source} = TemplateSelection.load_template_source(project.id, :not_found, nil)
|
||||
|
||||
assert source =~ ~s(data-template="not-found")
|
||||
assert source =~ "404"
|
||||
end
|
||||
|
||||
test "bundled defaults resolve even when project has no templates directory", %{
|
||||
project: project
|
||||
} do
|
||||
template_dir = Path.join(BDS.Projects.project_data_dir(project), "templates")
|
||||
refute File.exists?(template_dir)
|
||||
|
||||
{:ok, source} = TemplateSelection.load_template_source(project.id, :post, nil)
|
||||
|
||||
assert source =~ ~s(data-template="single-post")
|
||||
end
|
||||
end
|
||||
|
||||
describe "end-to-end template lookup with rendering" do
|
||||
test "post renders with tag-specific template when no post template set", %{
|
||||
project: project
|
||||
|
||||
Reference in New Issue
Block a user