-
-
Save carlosdavis/225567 to your computer and use it in GitHub Desktop.
Event Fakers with tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gem 'faker' | |
| require 'faker' | |
| # Clean out what is there | |
| Event.delete_all | |
| # Makes a bunch of different types of events per day at a random time during work hours | |
| (30.days.ago.to_date..90.days.from_now.to_date).each do |date| | |
| rand(3).times do | |
| start = date.beginning_of_day + 8.hours + (rand(32) * 15).minutes | |
| Appointment.create :creator => User.find(:first, :order => 'rand()'), | |
| :starts_at => start, | |
| :ends_at => start + (rand(16) * 15).minutes, | |
| :account_id => 1, | |
| :name => "Meet with #{Faker::Name.name}", | |
| :tag_names => ['test', 'alpha', 'boot', 'boots', 'zebra', 'mate', 'appt-tag'] | |
| end | |
| rand(2).times do | |
| event = %w(birthday vacation sick trial).rand | |
| AllDay.create :creator => User.find(:first, :order => rand()), | |
| :starts_at => date, | |
| :ends_at => date + rand(4).days, | |
| :account_id => 1, | |
| :name => "#{Faker::Name.name}'s #{event}", | |
| :tag_names => ['test', 'alpha', 'boot', 'boots', 'zebra', 'mate', 'allday-tag'] | |
| end | |
| rand(3).times do | |
| start = date.beginning_of_day + 8.hours + (rand(32) * 15).minutes | |
| CourtDate.create :creator => User.find(:first, :order => rand()), | |
| :starts_at => start, | |
| :ends_at => start + ((3..5).to_a.rand * 15).minutes, | |
| :account_id => 1, | |
| :name => "Have a trial with #{Faker::Name.name}", | |
| :tag_names => ['test', 'alpha', 'boot', 'boots', 'zebra', 'mate', 'courtdate-tag'] | |
| end | |
| rand(3).times do | |
| Task.create :creator => User.find(:first, :order => rand()), | |
| :starts_at => date, | |
| :account_id => 1, | |
| :name => "Help #{Faker::Name.name} with FinDec", | |
| :tag_names => ['test', 'alpha', 'boot', 'boots', 'zebra', 'mate', 'task-tag'] | |
| end | |
| rand(2).times do | |
| start = date.beginning_of_day + 8.hours + (rand(32) * 15).minutes | |
| Deadline.create :creator => User.find(:first, :order => rand()), | |
| :starts_at => start, | |
| :account_id => 1, | |
| :name => "File docs for #{Faker::Name.name}", | |
| :tag_names => ['test', 'alpha', 'boot', 'boots', 'zebra', 'mate', 'deadline-tag'] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment