Don´t show draft banner if the card is not filled

This commit is contained in:
Jorge Manrubia
2025-11-03 14:47:29 +01:00
parent ebf8490c2b
commit 42a8b52fa1
3 changed files with 12 additions and 1 deletions
+4
View File
@@ -52,6 +52,10 @@ class Card < ApplicationRecord
end
end
def filled?
title.present? || description.present?
end
private
def set_default_title
self.title = "Untitled" if title.blank?
+1 -1
View File
@@ -1,4 +1,4 @@
<% if card.drafted? && (card.title.present? or card.description.present?) %>
<% if card.drafted? && card.filled? %>
<div class="card__banner min-width max-width" style="--card-color: <%= card.color %>;">
<span class="overflow-ellipsis">This is a draft, its only visible to you.</span>
<%= button_to card_publish_path(@card), class: "btn txt-small", style: "--btn-background: #{card.color}" do %>
+7
View File
@@ -160,4 +160,11 @@ class CardTest < ActiveSupport::TestCase
collection_changed_event = events_in_new_collection.find { |event| event.action == "card_collection_changed" }
assert collection_changed_event
end
test "a card is filled if it has either the title or the description set" do
assert Card.new(title: "Some title").filled?
assert Card.new(description: "Some description").filled?
assert_not Card.new.filled?
end
end