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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. JoinedTeamUser.delete_all
  12. JoinedTeamUser.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} - #{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} - #{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. joined_team_users = JoinedTeamUser.create!(
  36. user_id: user.id,
  37. team_id: Team.all.sample.id
  38. )
  39. end
  40. User.create! username: "admin", email: "admin@email.com", password: "azerty", is_admin: true
  41. puts "Created Admin"
  42. 30.times do |i|
  43. task = Task.create(
  44. name: Faker::Fantasy::Tolkien.character,
  45. description: Faker::Fantasy::Tolkien.poem,
  46. duration: rand(1..120),
  47. user_id: User.all.sample.id,
  48. activity_id: Activity.all.sample.id
  49. )
  50. puts "Created TASK ##{i} - #{task.name}"
  51. end