Commit 781d3050ad2947b05aee130ff5107646a283b0a8
1 parent
ca7ec7f4
Exists in
staging
and in
42 other branches
ActionItem1163: script to create sample data
Showing
1 changed file
with
44 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,44 @@ |
| 1 | +#!/usr/bin/env ruby | |
| 2 | +require File.dirname(__FILE__) + '/../config/environment' | |
| 3 | + | |
| 4 | +people = [] | |
| 5 | + | |
| 6 | +NAMES = %w[ José João Antonio Paulo Maria Joana Paula Angela ] | |
| 7 | +SURNAMES = %w[ Silva Santos Abreu Oliveira Machado Bonfim ] | |
| 8 | +User.destroy_all | |
| 9 | +print "Creating users: " | |
| 10 | +for name in NAMES | |
| 11 | + for surname in SURNAMES | |
| 12 | + full_name = [name, surname].join(' ') | |
| 13 | + user = User.create!( | |
| 14 | + :login => full_name.to_slug, | |
| 15 | + :email => full_name.to_slug + '@localhost.localdomain', | |
| 16 | + :password => 'test', | |
| 17 | + :password_confirmation => 'test' | |
| 18 | + ) | |
| 19 | + user.person.name = full_name | |
| 20 | + user.person.save! | |
| 21 | + people << user.person | |
| 22 | + | |
| 23 | + print '.'; $stdout.flush | |
| 24 | + end | |
| 25 | +end | |
| 26 | +puts | |
| 27 | + | |
| 28 | +VERBS = ['Save', 'I like', 'I hate', 'Use'] | |
| 29 | +STUFF = ['Free Software', 'Organic food', 'the wales', 'the environment', 'Barack Obama', 'Osama Bin Laden', 'Lula'] | |
| 30 | +Community.destroy_all | |
| 31 | +print "Creating communities: " | |
| 32 | +for verb in VERBS | |
| 33 | + for stuff in STUFF | |
| 34 | + name = [verb, stuff].join(' ') | |
| 35 | + community = Community.create!(:name => name) | |
| 36 | + rand(10).times do | |
| 37 | + community.add_member(people.rand) | |
| 38 | + end | |
| 39 | + print '.'; $stdout.flush | |
| 40 | + end | |
| 41 | +end | |
| 42 | +puts | |
| 43 | + | |
| 44 | + | ... | ... |