Don´t show draft banner if the card is not filled
This commit is contained in:
@@ -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,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, it’s only visible to you.</span>
|
||||
<%= button_to card_publish_path(@card), class: "btn txt-small", style: "--btn-background: #{card.color}" do %>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user