API de comptabilité horaire.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

seeds.rb 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. User.delete_all
  2. User.reset_pk_sequence
  3. Activity.delete_all
  4. Activity.reset_pk_sequence
  5. JoinedUserActivity.delete_all
  6. JoinedUserActivity.reset_pk_sequence
  7. Task.delete_all
  8. Task.reset_pk_sequence
  9. Team.delete_all
  10. Team.reset_pk_sequence
  11. Membership.delete_all
  12. Membership.reset_pk_sequence
  13. 3.times do |i|
  14. team = Team.create(name: Faker::Company.name, description: Faker::Company.catch_phrase)
  15. puts "Created TEAM ##{i+1} - #{team.name}"
  16. end
  17. 10.times do |i|
  18. name = Faker::Name.first_name.downcase
  19. user = User.create(username: "#{name}", email: "#{name}@email.com", password: "azerty")
  20. puts "Created USER ##{i+1} - #{user.username}"
  21. 2.times do
  22. activity = Activity.create(
  23. name: Faker::Science.element,
  24. client: Faker::Company.name,
  25. description: Faker::Company.catch_phrase,
  26. author_id: user.id
  27. )
  28. puts "Created ACTIVITY \"#{activity.name}\" for #{activity.client}"
  29. joined_user_activity = JoinedUserActivity.create(
  30. user_id: user.id,
  31. activity_id: activity.id
  32. )
  33. puts "Created ASSOCIATION ##{joined_user_activity.id}"
  34. end
  35. memberships = Membership.create(
  36. member_id: user.id,
  37. team_id: Team.all.sample.id,
  38. can_edit: true
  39. )
  40. # puts "USER ##{memberships.user_id} joined TEAM ##{memberships.team_id}"
  41. end
  42. User.create(username: "admin", email: "admin@email.com", password: "azerty", is_admin: true)
  43. puts "Created Admin"
  44. 30.times do |i|
  45. task = Task.create(
  46. name: Faker::Fantasy::Tolkien.character,
  47. description: Faker::Fantasy::Tolkien.poem,
  48. duration: rand(1..120),
  49. user_id: User.all.sample.id,
  50. activity_id: Activity.all.sample.id
  51. )
  52. puts "Created TASK ##{i+1} - #{task.name}"
  53. end