summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-18 03:56:05 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-18 03:56:05 +0200
commit10bd6ba5cc640f0a85a3adb3641a65ce5edf831d (patch)
treed8d21867d62b1dd1c156c66e7b2ca446eb7936f5
parentd90ba22e5eb5a7884235d062a7d1bb4f2a6bb04f (diff)
Give Trash a proper title on lazy construction
-rw-r--r--app/models/node.rb6
-rw-r--r--test/models/node_test.rb1
2 files changed, 6 insertions, 1 deletions
diff --git a/app/models/node.rb b/app/models/node.rb
index 19669ca..b5b18a1 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -75,7 +75,11 @@ class Node < ApplicationRecord
75 # exist for that. 75 # exist for that.
76 def self.trash 76 def self.trash
77 root.children.find_by(:slug => CccConventions::TRASH_SLUG) || 77 root.children.find_by(:slug => CccConventions::TRASH_SLUG) ||
78 root.children.create!(:slug => CccConventions::TRASH_SLUG) 78 root.children.create!(:slug => CccConventions::TRASH_SLUG).tap do |node|
79 Globalize.with_locale(I18n.default_locale) do
80 node.draft.update!(:title => "Trash")
81 end
82 end
79 end 83 end
80 84
81 # Instance Methods 85 # Instance Methods
diff --git a/test/models/node_test.rb b/test/models/node_test.rb
index 3fb2d23..ab66f81 100644
--- a/test/models/node_test.rb
+++ b/test/models/node_test.rb
@@ -817,6 +817,7 @@ class NodeTest < ActiveSupport::TestCase
817 end 817 end
818 assert Node.trash.trash_node? 818 assert Node.trash.trash_node?
819 assert_not Node.trash.in_trash? 819 assert_not Node.trash.in_trash?
820 assert_equal "Trash", Globalize.with_locale(I18n.default_locale) { Node.trash.draft.title }
820 end 821 end
821 822
822 test "in_trash? walks the whole parent chain" do 823 test "in_trash? walks the whole parent chain" do