feat: H1 to H2 setting with the admin save conversion (tracer)
- content_h1_to_h2 and generic_anchors on the settings row (migration
202610280001), Headings and links tab, config key
golem15.journal.content_h1_to_h2 used when no settings row exists
- classes.ConvertH1 on the x/net/html tokenizer; the Blog Editor types
convert while the setting is on and answer editor.h1_converted
- GET /posts/{slug} reports content_h1_to_h2 (additive key)
This commit is contained in:
@@ -28,9 +28,20 @@ func TestCategoryContentMigration(t *testing.T) {
|
||||
t.Fatalf("migrate: %v", err)
|
||||
}
|
||||
|
||||
all := All()
|
||||
if last := all[len(all)-1].ID; last != "202610090001_add_content_to_golem15_journal_categories" {
|
||||
t.Fatalf("last migration = %s, want 202610090001_add_content_to_golem15_journal_categories", last)
|
||||
// The content column's step and the one before it: later migrations
|
||||
// are rolled back with it, so the test does not depend on being last.
|
||||
const contentStep = "202610090001_add_content_to_golem15_journal_categories"
|
||||
previous := ""
|
||||
for i, mig := range All() {
|
||||
if mig.ID == contentStep {
|
||||
if i == 0 {
|
||||
t.Fatalf("%s is the first migration", contentStep)
|
||||
}
|
||||
previous = All()[i-1].ID
|
||||
}
|
||||
}
|
||||
if previous == "" {
|
||||
t.Fatalf("migration %s is not registered", contentStep)
|
||||
}
|
||||
if !gdb.Migrator().HasColumn("golem15_journal_categories", "content") {
|
||||
t.Fatal("golem15_journal_categories.content missing")
|
||||
@@ -49,8 +60,8 @@ func TestCategoryContentMigration(t *testing.T) {
|
||||
if err := gdb.Exec(`UPDATE golem15_journal_categories SET content = '<p>x</p>' WHERE slug = 'uncategorized'`).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := m.RollbackLast(); err != nil {
|
||||
t.Fatalf("rollback last: %v", err)
|
||||
if err := m.RollbackTo(previous); err != nil {
|
||||
t.Fatalf("rollback to %s: %v", previous, err)
|
||||
}
|
||||
if !gdb.Migrator().HasTable("golem15_journal_categories") {
|
||||
t.Fatal("golem15_journal_categories dropped by the content rollback")
|
||||
|
||||
Reference in New Issue
Block a user