Files
astuto/db/seeds.rb

76 lines
2.0 KiB
Ruby
Raw Normal View History

2019-08-24 13:35:01 +02:00
# Create an admin user and confirm its email automatically
2019-09-23 18:41:38 +02:00
admin = User.create(
full_name: 'Admin',
email: 'admin@example.com',
password: 'password',
role: 'admin',
confirmed_at: Time.zone.now
)
2019-08-24 13:35:01 +02:00
2019-08-25 11:26:28 +02:00
# Create some boards
feature_board = Board.create(
name: 'Feature Requests',
description: 'Let us know about new features you would like to see in our product!',
order: 0
)
bug_board = Board.create(
name: 'Bug Reports',
description: 'Tell us everything about problems you encountered in our services!',
order: 1
)
2019-08-24 13:35:01 +02:00
# Create some post statuses
planned_post_status = PostStatus.create(
name: 'Planned',
color: '#0096ff',
order: 0,
show_in_roadmap: true
)
in_progress_post_status = PostStatus.create(
name: 'In Progress',
color: '#9437ff',
order: 1,
show_in_roadmap: true
)
completed_post_status = PostStatus.create(
name: 'Completed',
color: '#6ac47c',
order: 2,
show_in_roadmap: true
)
rejected_post_status = PostStatus.create(
name: 'Rejected',
color: '#ff2600',
order: 3,
show_in_roadmap: false
)
2019-08-24 13:35:01 +02:00
2019-08-25 11:26:28 +02:00
# Create some posts
2019-09-16 18:02:52 +02:00
post1 = Post.create(
2019-08-25 11:26:28 +02:00
title: 'This is how users give you feedback',
description: 'They can also provide an extendend description like this... bla bla...',
board_id: feature_board.id,
user_id: admin.id
)
2019-09-16 18:02:52 +02:00
post2 = Post.create(
2019-08-25 11:26:28 +02:00
title: 'You can assign a status to each post',
description: 'This one, for example, is marked as "Planned"',
board_id: feature_board.id,
user_id: admin.id,
post_status_id: planned_post_status.id
)
2019-09-16 18:02:52 +02:00
post3 = Post.create(
2019-08-25 11:26:28 +02:00
title: 'There are multiple boards',
description: 'For now you have Feature Requests and Bug Reports, but you can add or remove as many as you want!',
board_id: bug_board.id,
user_id: admin.id,
post_status_id: in_progress_post_status.id
)
2019-09-16 18:02:52 +02:00
# Create some comments
post1.comments.create(body: 'Users can comment to express their opinions!', user_id: admin.id)
2019-08-25 11:26:28 +02:00
# Let the user know how to log in with admin account
puts 'A default admin account has been created. Credentials:'
2019-08-24 13:35:01 +02:00
puts "-> email: #{admin.email}"
puts "-> password: #{admin.password}"