From 10bd6ba5cc640f0a85a3adb3641a65ce5edf831d Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 18 Jul 2026 03:56:05 +0200 Subject: Give Trash a proper title on lazy construction --- app/models/node.rb | 6 +++++- test/models/node_test.rb | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) 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 # exist for that. def self.trash root.children.find_by(:slug => CccConventions::TRASH_SLUG) || - root.children.create!(:slug => CccConventions::TRASH_SLUG) + root.children.create!(:slug => CccConventions::TRASH_SLUG).tap do |node| + Globalize.with_locale(I18n.default_locale) do + node.draft.update!(:title => "Trash") + end + end end # 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 end assert Node.trash.trash_node? assert_not Node.trash.in_trash? + assert_equal "Trash", Globalize.with_locale(I18n.default_locale) { Node.trash.draft.title } end test "in_trash? walks the whole parent chain" do -- cgit v1.3