summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-18 16:32:10 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-18 16:32:10 +0200
commita8cf4bd01625ebd341d32ec735a4b885db4c8118 (patch)
tree6a42ea2a86a907cc13c9a6447d990ffa3b145a2c
parent0c6783816e0a7a8acad922296d3eb8cc454fb981 (diff)
Accept blank template names in the allowlist validationsHEADmaster
-rw-r--r--app/models/node.rb6
-rw-r--r--app/models/page.rb6
-rw-r--r--test/models/page_test.rb3
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
31 validate :reserved_slug_stays_reserved 31 validate :reserved_slug_stays_reserved
32 validate :no_head_inside_trash 32 validate :no_head_inside_trash
33 validates :default_template_name, 33 validates :default_template_name,
34 :inclusion => { :in => ->(_) { Page.custom_templates } }, 34 :inclusion => { :in => ->(_) { Page.custom_templates } },
35 :allow_nil => true, 35 :allow_blank => true,
36 :if => :default_template_name_changed? 36 :if => :default_template_name_changed?
37 37
38 # Everything outside the Trash subtree, the Trash node included. 38 # Everything outside the Trash subtree, the Trash node included.
39 # Relies on unique_name being authoritative for tree position -- 39 # 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
17 # vanished stay saveable -- valid_template already falls back to 17 # vanished stay saveable -- valid_template already falls back to
18 # standard_template for those at render time. 18 # standard_template for those at render time.
19 validates :template_name, 19 validates :template_name,
20 :inclusion => { :in => ->(_) { Page.custom_templates } }, 20 :inclusion => { :in => ->(_) { Page.custom_templates } },
21 :allow_nil => true, 21 :allow_blank => true,
22 :if => :template_name_changed? 22 :if => :template_name_changed?
23 23
24 # Associations 24 # Associations
25 belongs_to :node, optional: true 25 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
393 393
394 page.template_name = "standard_template" 394 page.template_name = "standard_template"
395 assert page.valid? 395 assert page.valid?
396
397 page.template_name = ""
398 assert page.valid?
396 end 399 end
397 400
398 test "a stale legacy template_name does not block unrelated saves" do 401 test "a stale legacy template_name does not block unrelated saves" do