2023-06-20 09:52:02 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
Fabricator(:custom_topic, from: :topic) do
|
|
|
|
transient :custom_topic_name
|
|
|
|
transient :value
|
|
|
|
after_create do |top, transients|
|
2024-09-10 14:26:11 +08:00
|
|
|
if transients[:custom_topic_name] == DiscourseSolved::ACCEPTED_ANSWER_POST_ID_CUSTOM_FIELD
|
2024-09-05 17:55:02 +08:00
|
|
|
post = Fabricate(:post)
|
|
|
|
Fabricate(:solution, topic_id: top.id, answer_post_id: post.id)
|
|
|
|
end
|
2023-06-20 09:52:02 -05:00
|
|
|
custom_topic =
|
|
|
|
TopicCustomField.new(
|
|
|
|
topic_id: top.id,
|
|
|
|
name: transients[:custom_topic_name],
|
|
|
|
value: transients[:value],
|
|
|
|
)
|
|
|
|
custom_topic.save
|
|
|
|
end
|
|
|
|
end
|