Revert "Set default "Untitled" title for published cards"

This reverts commit ca1e002806.
This commit is contained in:
Jorge Manrubia
2025-05-01 13:10:36 +02:00
parent db50b643b3
commit 448989bfa2
2 changed files with 4 additions and 15 deletions
+4 -7
View File
@@ -11,8 +11,6 @@ class Card < ApplicationRecord
has_markdown :description
before_save :set_default_title
scope :reverse_chronologically, -> { order created_at: :desc, id: :desc }
scope :chronologically, -> { order created_at: :asc, id: :asc }
scope :latest, -> { order updated_at: :desc, id: :desc }
@@ -27,12 +25,11 @@ class Card < ApplicationRecord
end
end
def title=(new_title)
self[:title] = new_title.presence || "Untitled"
end
def cache_key
[ super, collection.name ].compact.join("/")
end
private
def set_default_title
self.title = "Untitled" if published? && title.blank?
end
end
-8
View File
@@ -120,12 +120,4 @@ class CardTest < ActiveSupport::TestCase
assert_includes card.cache_key, ApplicationRecord.current_tenant, "cache key must always include the tenant"
end
test "for published cards, it should set the default title 'Untitiled' when not provided" do
card = collections(:writebook).cards.create!
assert_nil card.title
card.publish
assert_equal "Untitled", card.reload.title
end
end