-
Notifications
You must be signed in to change notification settings - Fork 208
/
seeds.rb
49 lines (42 loc) · 1.3 KB
/
seeds.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Fake users
USERS = []
# basic account
USERS << User.create({login: 'harry', name: 'harry potter', email: '[email protected]'})
# admin account
u_admin = User.create({login: 'albus', name: 'albus dumbledore', email: '[email protected]', role: 'admin'})
USERS.push(u_admin)
# a few randomized basic accounts to have varied map authors
5.times do
user = User.create({login: Faker::Internet.username,
name: Faker::Name.name,
email: Faker::Internet.email})
USERS.push(user)
end
# Now faking Maps....
maps = []
30.times do
map = Map.new(
name: Faker::Address.city,
lat: Faker::Address.latitude,
lon: Faker::Address.longitude,
location: Faker::Address.country,
description: Faker::Lorem.sentence,
slug: Faker::Lorem.word
)
map.user = (USERS.sample)
map.author = map.user.login
map.save
maps. << map
end
# Fake maps images
maps.each do |map|
image = map.warpables.new
image.id = Faker::Number.unique.between(from: 10, to: 100)
image.history = Faker::Lorem.word
image.image_file_name = 'demo.png'
image.width = 500
system("mkdir -p public/system/images/#{image.id}/original")
system("cp test/fixtures/demo.png public/system/images/#{image.id}/original/demo.png")
image.image_content_type = 'image/png'
image.save
end