From a8cf4bd01625ebd341d32ec735a4b885db4c8118 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 18 Jul 2026 16:32:10 +0200 Subject: Accept blank template names in the allowlist validations --- app/models/node.rb | 6 +++--- app/models/page.rb | 6 +++--- test/models/page_test.rb | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/models/node.rb b/app/models/node.rb index b5b18a1..a440c2f 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -31,9 +31,9 @@ class Node < ApplicationRecord validate :reserved_slug_stays_reserved validate :no_head_inside_trash validates :default_template_name, - :inclusion => { :in => ->(_) { Page.custom_templates } }, - :allow_nil => true, - :if => :default_template_name_changed? + :inclusion => { :in => ->(_) { Page.custom_templates } }, + :allow_blank => true, + :if => :default_template_name_changed? # Everything outside the Trash subtree, the Trash node included. # Relies on unique_name being authoritative for tree position -- diff --git a/app/models/page.rb b/app/models/page.rb index c4d66fc..f33d88d 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -17,9 +17,9 @@ class Page < ApplicationRecord # vanished stay saveable -- valid_template already falls back to # standard_template for those at render time. validates :template_name, - :inclusion => { :in => ->(_) { Page.custom_templates } }, - :allow_nil => true, - :if => :template_name_changed? + :inclusion => { :in => ->(_) { Page.custom_templates } }, + :allow_blank => true, + :if => :template_name_changed? # Associations belongs_to :node, optional: true diff --git a/test/models/page_test.rb b/test/models/page_test.rb index 58794d5..1f924f9 100644 --- a/test/models/page_test.rb +++ b/test/models/page_test.rb @@ -393,6 +393,9 @@ class PageTest < ActiveSupport::TestCase page.template_name = "standard_template" assert page.valid? + + page.template_name = "" + assert page.valid? end test "a stale legacy template_name does not block unrelated saves" do -- cgit v1.3