No need to create a default collection
The playground is enough
This commit is contained in:
@@ -3,8 +3,6 @@ module Account::Seedeable
|
||||
|
||||
def setup_basic_template
|
||||
user = User.first
|
||||
|
||||
Collection.create!(name: "Cards", creator: user, all_access: true)
|
||||
end
|
||||
|
||||
def setup_customer_template
|
||||
|
||||
@@ -12,13 +12,4 @@ class Collection < ApplicationRecord
|
||||
|
||||
scope :alphabetically, -> { order("lower(name)") }
|
||||
scope :ordered_by_recently_accessed, -> { merge(Access.ordered_by_recently_accessed) }
|
||||
|
||||
after_destroy_commit :ensure_default_collection
|
||||
|
||||
private
|
||||
def ensure_default_collection
|
||||
if Collection.count.zero?
|
||||
Collection.create!(name: "Cards")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<% if Current.user.collections.many? %>
|
||||
<%= form_with model: collection, class: "txt-align-center margin-block-start-auto", method: :delete do |form| %>
|
||||
<%= form.button class: "btn txt-negative borderless txt-small", data: { turbo_confirm: "Are you sure you want to permanently delete this board?" } do %>
|
||||
<%= icon_tag "trash" %>
|
||||
<span>Delete this board</span>
|
||||
<% end %>
|
||||
<%= form_with model: collection, class: "txt-align-center margin-block-start-auto", method: :delete do |form| %>
|
||||
<%= form.button class: "btn txt-negative borderless txt-small", data: { turbo_confirm: "Are you sure you want to permanently delete this board?" } do %>
|
||||
<%= icon_tag "trash" %>
|
||||
<span>Delete this board</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -5,18 +5,10 @@ class Account::SedeableTest < ActiveSupport::TestCase
|
||||
@account = Account.sole
|
||||
end
|
||||
|
||||
test "setup_basic_template adds collections" do
|
||||
assert_changes -> { Collection.count } do
|
||||
@account.setup_basic_template
|
||||
end
|
||||
end
|
||||
|
||||
test "setup_customer_template adds collections, cards, and comments" do
|
||||
assert_changes -> { Collection.count } do
|
||||
assert_changes -> { Card.count } do
|
||||
assert_changes -> { Comment.count } do
|
||||
@account.setup_customer_template
|
||||
end
|
||||
@account.setup_customer_template
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user