Update seeds from "Collection" to "Board"
This commit is contained in:
+4
-4
@@ -51,12 +51,12 @@ def login_as(user)
|
||||
Current.session = user.identity.sessions.create
|
||||
end
|
||||
|
||||
def create_collection(name, creator: Current.user, all_access: true, access_to: [])
|
||||
Collection.create!(name:, creator:, all_access:).tap { it.accesses.grant_to(access_to) }
|
||||
def create_board(name, creator: Current.user, all_access: true, access_to: [])
|
||||
Board.create!(name:, creator:, all_access:).tap { it.accesses.grant_to(access_to) }
|
||||
end
|
||||
|
||||
def create_card(title, collection:, description: nil, status: :published, creator: Current.user)
|
||||
collection.cards.create!(title:, description:, creator:, status:)
|
||||
def create_card(title, board:, description: nil, status: :published, creator: Current.user)
|
||||
board.cards.create!(title:, description:, creator:, status:)
|
||||
end
|
||||
|
||||
# Seed accounts
|
||||
|
||||
@@ -7,17 +7,17 @@ kevin = find_or_create_user "Kevin Mcconnell", "kevin@37signals.com"
|
||||
|
||||
login_as david
|
||||
|
||||
create_collection("Fizzy", access_to: [ jason, jz, kevin ]).tap do |fizzy|
|
||||
create_card("Prepare sign-up page", description: "We need to do this before the launch.", collection: fizzy)
|
||||
create_board("Fizzy", access_to: [ jason, jz, kevin ]).tap do |fizzy|
|
||||
create_card("Prepare sign-up page", description: "We need to do this before the launch.", board: fizzy)
|
||||
|
||||
create_card("Prepare sign-up page", description: "We need to do this before the launch.", collection: fizzy).tap do |card|
|
||||
create_card("Prepare sign-up page", description: "We need to do this before the launch.", board: fizzy).tap do |card|
|
||||
card.toggle_assignment(kevin)
|
||||
if column = card.collection&.columns&.sample
|
||||
if column = card.board&.columns&.sample
|
||||
card.triage_into(column)
|
||||
end
|
||||
end
|
||||
|
||||
create_card("Plain text mentions", description: "We'll support plain text mentions first.", collection: fizzy).tap do |card|
|
||||
create_card("Plain text mentions", description: "We'll support plain text mentions first.", board: fizzy).tap do |card|
|
||||
card.toggle_assignment(david)
|
||||
card.close
|
||||
end
|
||||
|
||||
+6
-6
@@ -24,7 +24,7 @@ card_titles = [
|
||||
"Set up CI/CD"
|
||||
]
|
||||
|
||||
collections = [
|
||||
boards = [
|
||||
"Project Launch",
|
||||
"Frontend Dev",
|
||||
"Backend Dev",
|
||||
@@ -34,13 +34,13 @@ collections = [
|
||||
|
||||
time_range = (60 .. 30.days.in_minutes)
|
||||
|
||||
collections.each_with_index do |collection_name, index|
|
||||
create_collection(collection_name, access_to: authors.sample(3)).tap do |collection|
|
||||
boards.each_with_index do |board_name, index|
|
||||
create_board(board_name, access_to: authors.sample(3)).tap do |board|
|
||||
card_titles.each do |title|
|
||||
travel(-rand(time_range).minutes) do
|
||||
card = create_card title,
|
||||
description: "#{title} for #{collection_name} phase #{index + 1}.",
|
||||
collection: collection,
|
||||
description: "#{title} for #{board_name} phase #{index + 1}.",
|
||||
board: board,
|
||||
creator: authors.sample
|
||||
|
||||
# Randomly assign to 1-2 authors
|
||||
@@ -56,7 +56,7 @@ collections.each_with_index do |collection_name, index|
|
||||
travel rand(0..20).minutes
|
||||
case rand(3)
|
||||
when 0
|
||||
if column = card.collection&.columns&.sample
|
||||
if column = card.board&.columns&.sample
|
||||
card.triage_into(column)
|
||||
end
|
||||
when 1
|
||||
|
||||
Reference in New Issue
Block a user