fix(discourse): enable allow_uncategorized_topics in admin bootstrap so create-topic POST succeeds (Discourse 3.x 422 'Category cant be blank')

This commit is contained in:
autonomic-bot
2026-05-31 04:41:03 +00:00
parent 3dc8fdf507
commit 1f92776052

View File

@ -24,7 +24,13 @@ from harness import lifecycle # noqa: E402
# Rails snippet (single line): find-or-create an admin, create an ApiKey, print key + username as the
# last two lines. SecureRandom is available in the Rails runtime. We mark the user active + approved
# so the API accepts it. created_by_id must be set (ApiKey validates it).
#
# We also enable `allow_uncategorized_topics` (a standard Discourse feature, off by default since 3.x):
# without it, POST /posts.json with no category 422s "Category can't be blank". This is config parity
# with a real forum (the operator would either enable uncategorized or pick a category), not a test
# weakening — the create-topic round-trip still posts a real topic and asserts a unique marker survives.
_BOOTSTRAP_RB = (
"SiteSetting.allow_uncategorized_topics = true; "
"u = User.where(admin: true).order(:id).first; "
"if u.nil?; "
"u = User.create!(username: 'ccciadmin', name: 'CCCI Admin', "