No default columns for new collections
https://3.basecamp.com/2914079/buckets/37331921/todos/9104429380#__recording_9118363137
This commit is contained in:
@@ -1,19 +1,7 @@
|
||||
module Collection::Triageable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
DEFAULT_COLUMNS = [
|
||||
{ name: "Figuring it out", color: "var(--color-card-5)" },
|
||||
{ name: "In progress", color: "var(--color-card-3)" }
|
||||
]
|
||||
|
||||
included do
|
||||
has_many :columns, dependent: :destroy
|
||||
|
||||
after_create_commit :create_default_columns
|
||||
end
|
||||
|
||||
private
|
||||
def create_default_columns
|
||||
Column.insert_all(DEFAULT_COLUMNS.map { { name: it[:name], color: it[:color], collection_id: id } })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
require "test_helper"
|
||||
|
||||
class Collection::TriageableTest < ActiveSupport::TestCase
|
||||
test "creating collection creates default columns" do
|
||||
assert_difference -> { Column.count }, Collection::Triageable::DEFAULT_COLUMNS.size do
|
||||
collection = Collection.create! name: "Test Collection", creator: users(:david)
|
||||
|
||||
assert_equal Collection::Triageable::DEFAULT_COLUMNS.size, collection.columns.count
|
||||
|
||||
Collection::Triageable::DEFAULT_COLUMNS.each_with_index do |default_column, index|
|
||||
column = collection.columns.order(:id)[index]
|
||||
assert_equal default_column[:name], column.name
|
||||
assert_equal default_column[:color], column.color
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user