2019-04-30 10:27:42 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-01 15:11:48 -05:00
|
|
|
Fabricator(:category) do
|
|
|
|
name { sequence(:name) { |n| "Amazing Category #{n}" } }
|
2019-08-06 11:26:54 +01:00
|
|
|
skip_category_definition true
|
2023-06-07 13:09:30 +09:00
|
|
|
color { SecureRandom.hex(3) }
|
2017-03-01 15:11:48 -05:00
|
|
|
user
|
|
|
|
end
|
|
|
|
|
2019-08-06 11:26:54 +01:00
|
|
|
Fabricator(:category_with_definition, from: :category) { skip_category_definition false }
|
|
|
|
|
2023-05-19 07:37:23 -05:00
|
|
|
Fabricator(:category_with_group_and_permission, from: :category) do
|
2017-03-01 15:11:48 -05:00
|
|
|
transient :group
|
2022-12-23 14:18:29 +11:00
|
|
|
transient :permission_type
|
2017-03-01 15:11:48 -05:00
|
|
|
|
2020-02-12 12:11:28 +02:00
|
|
|
name { sequence(:name) { |n| "Private Category #{n}" } }
|
|
|
|
slug { sequence(:slug) { |n| "private#{n}" } }
|
2017-03-01 15:11:48 -05:00
|
|
|
user
|
2020-02-12 12:11:28 +02:00
|
|
|
|
2017-03-01 15:11:48 -05:00
|
|
|
after_build do |cat, transients|
|
2022-12-23 14:18:29 +11:00
|
|
|
cat.category_groups.build(
|
|
|
|
group_id: transients[:group].id,
|
|
|
|
permission_type: transients[:permission_type] || CategoryGroup.permission_types[:full],
|
|
|
|
)
|
2017-03-01 15:11:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-05-19 07:37:23 -05:00
|
|
|
Fabricator(:private_category, from: :category_with_group_and_permission) do
|
|
|
|
after_build { |cat, transients| cat.update!(read_restricted: true) }
|
|
|
|
end
|
|
|
|
|
2019-08-06 11:26:54 +01:00
|
|
|
Fabricator(:private_category_with_definition, from: :private_category) do
|
|
|
|
skip_category_definition false
|
|
|
|
end
|
2020-02-12 12:11:28 +02:00
|
|
|
|
2017-03-01 15:11:48 -05:00
|
|
|
Fabricator(:link_category, from: :category) do
|
2022-07-26 01:47:09 +02:00
|
|
|
before_create { |category, transients| category.topic_featured_link_allowed = true }
|
2015-03-02 11:25:25 -08:00
|
|
|
end
|
2017-11-17 14:48:48 +01:00
|
|
|
|
|
|
|
Fabricator(:mailinglist_mirror_category, from: :category) do
|
|
|
|
email_in "list@example.com"
|
|
|
|
email_in_allow_strangers true
|
|
|
|
mailinglist_mirror true
|
|
|
|
end
|