From 42a8b52fa1dd138e202647d9ab8f59ae255b50f2 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Mon, 3 Nov 2025 14:47:29 +0100 Subject: [PATCH] =?UTF-8?q?Don=C2=B4t=20show=20draft=20banner=20if=20the?= =?UTF-8?q?=20card=20is=20not=20filled?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/card.rb | 4 ++++ app/views/cards/container/_status.html.erb | 2 +- test/models/card_test.rb | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models/card.rb b/app/models/card.rb index cdc32824d..7ac40ca09 100644 --- a/app/models/card.rb +++ b/app/models/card.rb @@ -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? diff --git a/app/views/cards/container/_status.html.erb b/app/views/cards/container/_status.html.erb index dcdc28c56..492130b9e 100644 --- a/app/views/cards/container/_status.html.erb +++ b/app/views/cards/container/_status.html.erb @@ -1,4 +1,4 @@ -<% if card.drafted? && (card.title.present? or card.description.present?) %> +<% if card.drafted? && card.filled? %>
This is a draft, it’s only visible to you. <%= button_to card_publish_path(@card), class: "btn txt-small", style: "--btn-background: #{card.color}" do %> diff --git a/test/models/card_test.rb b/test/models/card_test.rb index 82920b323..635d5a581 100644 --- a/test/models/card_test.rb +++ b/test/models/card_test.rb @@ -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