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.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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::Verb.ing_form,
  47. description: Faker::Fantasy::Tolkien.poem,
  48. start_time: Faker::Time.between(from: DateTime.now - 1, to: DateTime.now),
  49. end_time: Faker::Time.between(from: DateTime.now + 1, to: DateTime.now + 5),
  50. owner_id: User.all.sample.id,
  51. activity_id: Activity.all.sample.id
  52. )
  53. puts "Created TASK ##{i+1} - #{task.name}"
  54. end