-
Notifications
You must be signed in to change notification settings - Fork 19
/
factories.rb
76 lines (65 loc) · 2.25 KB
/
factories.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
FactoryBot.define do
factory :user do
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
email { Faker::Internet.email }
password { Faker::Internet.password }
roles { { admin: false, manager: [true, false].sample, editor: [true, false].sample, writer: [true, false].sample } }
birthday { Faker::Date.birthday(min_age: 18, max_age: 65) }
end
factory :team do
name { Faker::Company.unique.name }
description { Faker::Lorem.paragraph(sentence_count: 4) }
end
factory :post do
name { Faker::Quote.famous_last_words }
body { Faker::Lorem.paragraphs(number: rand(4...10)).join("\n") }
is_featured { [true, false].sample }
published_at do
if [false, true].sample
Time.now - rand(10...365).days
else
nil
end
end
status { Post.statuses.values.sample }
end
factory :comment do
body { Faker::Lorem.paragraphs(number: rand(4...10)).join("\n") }
end
factory :project do
name { Faker::App.name }
status { [:closed, :rejected, :failed, :loading, :running, :waiting, :done, :finalized, :archived, :finished].sample }
stage { ['discovery', 'idea', 'done', 'on hold', 'cancelled'].sample }
budget { Faker::Number.decimal(l_digits: 4) }
country { Faker::Address.country_code }
users_required { Faker::Number.between(from: 10, to: 100) }
started_at { Time.now - rand(10...365).days }
meta { [{ foo: 'bar', hey: 'hi' }, { bar: 'baz' }, { hoho: 'hohoho' }].sample }
progress { Faker::Number.between(from: 0, to: 100) }
end
factory :review do
body { Faker::Lorem.paragraphs(number: rand(4...10)).join("\n") }
end
factory :person do
name { "#{Faker::Name.first_name} #{Faker::Name.last_name}" }
end
factory :spouse do
name { "#{Faker::Name.first_name} #{Faker::Name.last_name}" }
type { "Spouse" }
end
factory :link do
name { Faker::Internet.url }
end
factory :fish do
name { %w(Tilapia Salmon Trout Catfish Pangasius Carp).sample }
end
factory :course do
name { Faker::Educator.course_name }
country { Course.countries.sample }
city { Course.cities.stringify_keys[country].sample }
end
factory :course_link, class: 'Course::Link' do
link { Faker::Internet.url }
end
end