2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricator(:user_stat) {}
|
2013-10-03 22:28:49 -05:00
|
|
|
|
2019-04-23 04:49:05 -05:00
|
|
|
Fabricator(:user, class_name: :user) do
|
2023-11-06 22:03:25 -06:00
|
|
|
transient refresh_auto_groups: false
|
2024-01-29 03:52:02 -06:00
|
|
|
transient trust_level: nil
|
2023-11-06 22:03:25 -06:00
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
name "Bruce Wayne"
|
2013-02-05 13:16:51 -06:00
|
|
|
username { sequence(:username) { |i| "bruce#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "bruce#{i}@wayne.com" } }
|
2023-01-09 05:18:21 -06:00
|
|
|
password "myawesomepassword"
|
2017-07-27 20:20:09 -05:00
|
|
|
ip_address { sequence(:ip_address) { |i| "99.232.23.#{i % 254}" } }
|
2014-08-13 12:30:25 -05:00
|
|
|
active true
|
2023-11-06 22:03:25 -06:00
|
|
|
|
2024-01-29 03:52:02 -06:00
|
|
|
after_build { |user, transients| user.trust_level = transients[:trust_level] || TrustLevel[1] }
|
|
|
|
|
2023-11-06 22:03:25 -06:00
|
|
|
after_create do |user, transients|
|
2024-01-29 03:52:02 -06:00
|
|
|
if transients[:refresh_auto_groups] || transients[:trust_level]
|
|
|
|
Group.user_trust_level_change!(user.id, user.trust_level)
|
|
|
|
end
|
2023-11-06 22:03:25 -06:00
|
|
|
end
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
2019-04-23 04:49:05 -05:00
|
|
|
Fabricator(:user_with_secondary_email, from: :user) do
|
2018-07-03 06:51:22 -05:00
|
|
|
after_create { |user| Fabricate(:secondary_email, user: user) }
|
2017-07-31 17:27:29 -05:00
|
|
|
end
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
Fabricator(:coding_horror, from: :user) do
|
2023-01-09 05:18:21 -06:00
|
|
|
name "Coding Horror"
|
|
|
|
username "CodingHorror"
|
|
|
|
email "jeff@somewhere.com"
|
|
|
|
password "mymoreawesomepassword"
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:evil_trout, from: :user) do
|
2023-01-09 05:18:21 -06:00
|
|
|
name "Evil Trout"
|
|
|
|
username "eviltrout"
|
|
|
|
email "eviltrout@somewhere.com"
|
|
|
|
password "imafish123"
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:walter_white, from: :user) do
|
2023-01-09 05:18:21 -06:00
|
|
|
name "Walter White"
|
|
|
|
username "heisenberg"
|
|
|
|
email "wwhite@bluemeth.com"
|
|
|
|
password "letscook123"
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
2014-10-24 18:20:41 -05:00
|
|
|
Fabricator(:inactive_user, from: :user) do
|
2023-01-09 05:18:21 -06:00
|
|
|
name "Inactive User"
|
|
|
|
username "inactive_user"
|
|
|
|
email "inactive@idontexist.com"
|
|
|
|
password "qwerqwer123"
|
2014-10-24 18:20:41 -05:00
|
|
|
active false
|
|
|
|
end
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
Fabricator(:moderator, from: :user) do
|
2017-07-27 20:20:09 -05:00
|
|
|
name { sequence(:name) { |i| "A#{i} Moderator" } }
|
|
|
|
username { sequence(:username) { |i| "moderator#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "moderator#{i}@discourse.org" } }
|
2013-03-19 23:05:19 -05:00
|
|
|
moderator true
|
2022-05-10 10:02:28 -05:00
|
|
|
|
|
|
|
after_create do |user|
|
|
|
|
user.group_users << Fabricate(:group_user, user: user, group: Group[:moderators])
|
2022-12-21 06:02:40 -06:00
|
|
|
user.group_users << Fabricate(:group_user, user: user, group: Group[:staff])
|
2022-05-10 10:02:28 -05:00
|
|
|
end
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:admin, from: :user) do
|
2023-01-09 05:18:21 -06:00
|
|
|
name "Anne Admin"
|
2017-07-27 20:20:09 -05:00
|
|
|
username { sequence(:username) { |i| "anne#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "anne#{i}@discourse.org" } }
|
2013-02-05 13:16:51 -06:00
|
|
|
admin true
|
2024-03-25 22:41:12 -05:00
|
|
|
trust_level TrustLevel[4]
|
2022-05-10 10:02:28 -05:00
|
|
|
|
|
|
|
after_create do |user|
|
|
|
|
user.group_users << Fabricate(:group_user, user: user, group: Group[:admins])
|
2022-12-21 06:02:40 -06:00
|
|
|
user.group_users << Fabricate(:group_user, user: user, group: Group[:staff])
|
2022-05-10 10:02:28 -05:00
|
|
|
end
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
2013-04-17 18:11:13 -05:00
|
|
|
Fabricator(:newuser, from: :user) do
|
2023-01-09 05:18:21 -06:00
|
|
|
name "Newbie Newperson"
|
|
|
|
username "newbie"
|
|
|
|
email "newbie@new.com"
|
2014-09-05 00:20:39 -05:00
|
|
|
trust_level TrustLevel[0]
|
2013-04-05 12:59:00 -05:00
|
|
|
end
|
2013-07-11 17:47:06 -05:00
|
|
|
|
|
|
|
Fabricator(:active_user, from: :user) do
|
2023-01-09 05:18:21 -06:00
|
|
|
name "Luke Skywalker"
|
2013-07-11 17:47:06 -05:00
|
|
|
username { sequence(:username) { |i| "luke#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "luke#{i}@skywalker.com" } }
|
2023-01-09 05:18:21 -06:00
|
|
|
password "myawesomepassword"
|
2014-09-05 00:20:39 -05:00
|
|
|
trust_level TrustLevel[1]
|
2014-06-10 00:19:08 -05:00
|
|
|
|
|
|
|
after_create do |user|
|
|
|
|
user.user_profile.bio_raw = "Don't ask me about my dad!"
|
|
|
|
user.user_profile.save!
|
|
|
|
end
|
2013-10-03 22:28:49 -05:00
|
|
|
end
|
2014-03-13 09:47:37 -05:00
|
|
|
|
|
|
|
Fabricator(:leader, from: :user) do
|
2023-01-09 05:18:21 -06:00
|
|
|
name "Veteran McVeteranish"
|
2014-03-13 09:47:37 -05:00
|
|
|
username { sequence(:username) { |i| "leader#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "leader#{i}@leaderfun.com" } }
|
2014-09-05 00:20:39 -05:00
|
|
|
trust_level TrustLevel[3]
|
2014-03-13 09:47:37 -05:00
|
|
|
end
|
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricator(:trust_level_0, from: :user) { trust_level TrustLevel[0] }
|
|
|
|
Fabricator(:trust_level_1, from: :user) { trust_level TrustLevel[1] }
|
2024-01-29 03:52:02 -06:00
|
|
|
Fabricator(:trust_level_2, from: :user) { trust_level TrustLevel[2] }
|
2023-01-17 02:50:15 -06:00
|
|
|
Fabricator(:trust_level_3, from: :user) { trust_level TrustLevel[3] }
|
|
|
|
|
2014-09-05 01:52:40 -05:00
|
|
|
Fabricator(:trust_level_4, from: :user) do
|
2023-01-09 05:18:21 -06:00
|
|
|
name "Leader McElderson"
|
2014-09-05 01:52:40 -05:00
|
|
|
username { sequence(:username) { |i| "tl4#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "tl4#{i}@elderfun.com" } }
|
2014-09-05 00:20:39 -05:00
|
|
|
trust_level TrustLevel[4]
|
2014-06-07 14:52:51 -05:00
|
|
|
end
|
2015-05-10 18:10:10 -05:00
|
|
|
|
|
|
|
Fabricator(:anonymous, from: :user) do
|
2023-01-09 05:18:21 -06:00
|
|
|
name ""
|
2015-05-10 18:10:10 -05:00
|
|
|
username { sequence(:username) { |i| "anonymous#{i}" } }
|
|
|
|
email { sequence(:email) { |i| "anonymous#{i}@anonymous.com" } }
|
|
|
|
trust_level TrustLevel[1]
|
2017-11-23 14:55:44 -06:00
|
|
|
manual_locked_trust_level TrustLevel[1]
|
2015-05-10 18:10:10 -05:00
|
|
|
|
2019-05-28 23:26:06 -05: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-10 18:10:10 -05:00
|
|
|
end
|
|
|
|
end
|
2015-11-09 10:37:33 -06:00
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricator(:staged, from: :user) { staged true }
|
2020-06-05 11:31:58 -05:00
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricator(:unicode_user, from: :user) { username { sequence(:username) { |i| "Löwe#{i}" } } }
|
2022-10-25 02:29:09 -05:00
|
|
|
|
|
|
|
Fabricator(:bot, from: :user) do
|
|
|
|
id do
|
|
|
|
min_id = User.minimum(:id)
|
|
|
|
[(min_id || 0) - 1, -10].min
|
|
|
|
end
|
|
|
|
end
|
2023-08-18 11:33:40 -05: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
|