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