2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-10-04 11:28:49 +08:00
|
|
|
Fabricator(:user_stat) {}
|
|
|
|
|
2019-04-23 17:49:05 +08:00
|
|
|
Fabricator(:user, class_name: :user) do
|
2023-11-07 12:03:25 +08:00
|
|
|
transient refresh_auto_groups: false
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
name "Bruce Wayne"
|
|
|
|
username { sequence(:username) { |i| "bruce#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "bruce#{i}@wayne.com" } }
|
|
|
|
password "myawesomepassword"
|
2014-09-05 13:20:39 +08:00
|
|
|
trust_level TrustLevel[1]
|
2013-10-12 01:33:23 +08:00
|
|
|
ip_address { sequence(:ip_address) { |i| "99.232.23.#{i % 254}" } }
|
2014-08-14 01:30:25 +08:00
|
|
|
active true
|
2023-11-07 12:03:25 +08:00
|
|
|
|
|
|
|
after_create do |user, transients|
|
|
|
|
Group.user_trust_level_change!(user.id, user.trust_level) if transients[:refresh_auto_groups]
|
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2019-04-23 17:49:05 +08:00
|
|
|
Fabricator(:user_with_secondary_email, from: :user) do
|
2018-07-03 19:51:22 +08:00
|
|
|
after_create { |user| Fabricate(:secondary_email, user: user) }
|
2017-08-01 06:27:29 +08:00
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
Fabricator(:coding_horror, from: :user) do
|
|
|
|
name "Coding Horror"
|
2013-02-26 00:42:20 +08:00
|
|
|
username "CodingHorror"
|
2013-02-06 03:16:51 +08:00
|
|
|
email "jeff@somewhere.com"
|
|
|
|
password "mymoreawesomepassword"
|
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:evil_trout, from: :user) do
|
|
|
|
name "Evil Trout"
|
2013-02-26 00:42:20 +08:00
|
|
|
username "eviltrout"
|
2013-02-06 03:16:51 +08:00
|
|
|
email "eviltrout@somewhere.com"
|
2017-12-01 12:19:24 +08:00
|
|
|
password "imafish123"
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:walter_white, from: :user) do
|
|
|
|
name "Walter White"
|
2013-02-26 00:42:20 +08:00
|
|
|
username "heisenberg"
|
2013-02-06 03:16:51 +08:00
|
|
|
email "wwhite@bluemeth.com"
|
2017-12-01 12:19:24 +08:00
|
|
|
password "letscook123"
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2014-10-25 07:20:41 +08:00
|
|
|
Fabricator(:inactive_user, from: :user) do
|
|
|
|
name "Inactive User"
|
|
|
|
username "inactive_user"
|
|
|
|
email "inactive@idontexist.com"
|
2017-04-06 04:14:22 +08:00
|
|
|
password "qwerqwer123"
|
2014-10-25 07:20:41 +08:00
|
|
|
active false
|
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
Fabricator(:moderator, from: :user) do
|
2013-05-31 23:41:40 +08:00
|
|
|
name { sequence(:name) { |i| "A#{i} Moderator" } }
|
|
|
|
username { sequence(:username) { |i| "moderator#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "moderator#{i}@discourse.org" } }
|
2013-03-20 12:05:19 +08:00
|
|
|
moderator true
|
2022-05-10 23:02:28 +08:00
|
|
|
|
|
|
|
after_create do |user|
|
|
|
|
user.group_users << Fabricate(:group_user, user: user, group: Group[:moderators])
|
2022-12-21 20:02:40 +08:00
|
|
|
user.group_users << Fabricate(:group_user, user: user, group: Group[:staff])
|
2022-05-10 23:02:28 +08:00
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:admin, from: :user) do
|
|
|
|
name "Anne Admin"
|
2013-05-31 23:41:40 +08:00
|
|
|
username { sequence(:username) { |i| "anne#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "anne#{i}@discourse.org" } }
|
2013-02-06 03:16:51 +08:00
|
|
|
admin true
|
2022-05-10 23:02:28 +08:00
|
|
|
|
|
|
|
after_create do |user|
|
|
|
|
user.group_users << Fabricate(:group_user, user: user, group: Group[:admins])
|
2022-12-21 20:02:40 +08:00
|
|
|
user.group_users << Fabricate(:group_user, user: user, group: Group[:staff])
|
2022-05-10 23:02:28 +08:00
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2013-04-18 07:11:13 +08:00
|
|
|
Fabricator(:newuser, from: :user) do
|
2013-04-06 01:59:00 +08:00
|
|
|
name "Newbie Newperson"
|
|
|
|
username "newbie"
|
|
|
|
email "newbie@new.com"
|
2014-09-05 13:20:39 +08:00
|
|
|
trust_level TrustLevel[0]
|
2013-04-06 01:59:00 +08:00
|
|
|
end
|
2013-07-12 06:47:06 +08:00
|
|
|
|
|
|
|
Fabricator(:active_user, from: :user) do
|
|
|
|
name "Luke Skywalker"
|
|
|
|
username { sequence(:username) { |i| "luke#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "luke#{i}@skywalker.com" } }
|
|
|
|
password "myawesomepassword"
|
2014-09-05 13:20:39 +08:00
|
|
|
trust_level TrustLevel[1]
|
2014-06-10 13:19:08 +08:00
|
|
|
|
|
|
|
after_create do |user|
|
|
|
|
user.user_profile.bio_raw = "Don't ask me about my dad!"
|
|
|
|
user.user_profile.save!
|
|
|
|
end
|
2013-10-04 11:28:49 +08:00
|
|
|
end
|
2014-03-13 22:47:37 +08:00
|
|
|
|
|
|
|
Fabricator(:leader, from: :user) do
|
2014-08-30 06:57:13 +08:00
|
|
|
name "Veteran McVeteranish"
|
2014-03-13 22:47:37 +08:00
|
|
|
username { sequence(:username) { |i| "leader#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "leader#{i}@leaderfun.com" } }
|
2014-09-05 13:20:39 +08:00
|
|
|
trust_level TrustLevel[3]
|
2014-03-13 22:47:37 +08:00
|
|
|
end
|
|
|
|
|
2021-08-05 17:38:39 +08:00
|
|
|
Fabricator(:trust_level_0, from: :user) { trust_level TrustLevel[0] }
|
|
|
|
|
|
|
|
Fabricator(:trust_level_1, from: :user) { trust_level TrustLevel[1] }
|
|
|
|
|
2023-01-17 16:50:15 +08:00
|
|
|
Fabricator(:trust_level_3, from: :user) { trust_level TrustLevel[3] }
|
|
|
|
|
2014-09-05 14:52:40 +08:00
|
|
|
Fabricator(:trust_level_4, from: :user) do
|
|
|
|
name "Leader McElderson"
|
|
|
|
username { sequence(:username) { |i| "tl4#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "tl4#{i}@elderfun.com" } }
|
2014-09-05 13:20:39 +08:00
|
|
|
trust_level TrustLevel[4]
|
2014-06-08 03:52:51 +08:00
|
|
|
end
|
2015-05-11 07:10:10 +08:00
|
|
|
|
|
|
|
Fabricator(:anonymous, from: :user) do
|
|
|
|
name ""
|
|
|
|
username { sequence(:username) { |i| "anonymous#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "anonymous#{i}@anonymous.com" } }
|
|
|
|
trust_level TrustLevel[1]
|
2017-11-24 04:55:44 +08:00
|
|
|
manual_locked_trust_level TrustLevel[1]
|
2015-05-11 07:10:10 +08:00
|
|
|
|
2019-05-29 12:26:06 +08:00
|
|
|
after_create do
|
|
|
|
# this is not "the perfect" fabricator in that user id -1 is system
|
|
|
|
# but creating a proper account here is real slow and has a huge
|
|
|
|
# impact on the test suite run time
|
|
|
|
create_anonymous_user_master(master_user_id: -1, active: true)
|
2015-05-11 07:10:10 +08:00
|
|
|
end
|
|
|
|
end
|
2015-11-10 00:37:33 +08:00
|
|
|
|
|
|
|
Fabricator(:staged, from: :user) { staged true }
|
2020-06-06 00:31:58 +08:00
|
|
|
|
|
|
|
Fabricator(:unicode_user, from: :user) { username { sequence(:username) { |i| "Löwe#{i}" } } }
|
2022-10-25 15:29:09 +08:00
|
|
|
|
|
|
|
Fabricator(:bot, from: :user) do
|
|
|
|
id do
|
|
|
|
min_id = User.minimum(:id)
|
|
|
|
[(min_id || 0) - 1, -10].min
|
|
|
|
end
|
|
|
|
end
|
2023-08-19 00:33:40 +08:00
|
|
|
|
|
|
|
Fabricator(:east_coast_user, from: :user) do
|
|
|
|
email "eastcoast@tz.com"
|
|
|
|
after_create do |user|
|
|
|
|
user.user_option = UserOption.new(timezone: "Eastern Time (US & Canada)")
|
|
|
|
user.save
|
|
|
|
end
|
|
|
|
end
|