-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
user_factories.rb
executable file
·66 lines (60 loc) · 2.44 KB
/
user_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
# frozen_string_literal: true
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
FactoryBot.define do
factory :user do
username { FFaker::InternetSE.user_name_variant_short }
email { FFaker::Internet.email }
first_name { FFaker::Name.first_name }
last_name { FFaker::Name.last_name }
title { FactoryBot.generate(:title) }
company { FFaker::Company.name }
alt_email { FFaker::Internet.email }
phone { FFaker::PhoneNumber.phone_number }
mobile { FFaker::PhoneNumber.phone_number }
aim { nil }
yahoo { nil }
google { nil }
skype { nil }
admin { false }
encrypted_password { SecureRandom.hex(64) }
password_salt { SecureRandom.hex(64) }
last_sign_in_at { FactoryBot.generate(:time) }
current_sign_in_at { FactoryBot.generate(:time) }
last_sign_in_ip { "127.0.0.1" }
current_sign_in_ip { "127.0.0.1" }
sign_in_count { rand(1..100) }
deleted_at { nil }
updated_at { FactoryBot.generate(:time) }
created_at { FactoryBot.generate(:time) }
suspended_at { nil }
password { "password" }
password_confirmation { "password" }
# For unit tests, we dont need to enforce uniqueness
to_create { |instance| instance.save(validate: false) }
end
factory :admin do
admin { true }
end
factory :permission do
user
asset { raise "Please specify :asset for the permission" }
updated_at { FactoryBot.generate(:time) }
created_at { FactoryBot.generate(:time) }
end
factory :preference do
user
name { raise "Please specify :name for the preference" }
value { raise "Please specify :value for the preference" }
updated_at { FactoryBot.generate(:time) }
created_at { FactoryBot.generate(:time) }
end
factory :group do
name { FFaker::Company.name }
updated_at { FactoryBot.generate(:time) }
created_at { FactoryBot.generate(:time) }
end
end