Revert "Set default "Untitled" title for published cards"
This reverts commit ca1e002806.
This commit is contained in:
+4
-7
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user