mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-06 14:44:13 +08:00
41 lines
1 KiB
Ruby
41 lines
1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
Fabricator(:template_item, from: :topic) do
|
|
transient :content
|
|
|
|
title { sequence(:title) { |i| "This is a test template #{i.to_s.rjust(6, "0")}" } }
|
|
|
|
after_create do |topic, transients|
|
|
Fabricate(:post, topic: topic) do
|
|
raw do
|
|
if transients[:content]
|
|
transients[:content]
|
|
else
|
|
sequence(:title) do |i|
|
|
"This is the content of an awesome template #{i.to_s.rjust(6, "0")}"
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
Fabricator(:private_template_item, from: :private_message_topic) do
|
|
transient :content
|
|
|
|
title { sequence(:title) { |i| "This is a private test template #{i.to_s.rjust(6, "0")}" } }
|
|
|
|
after_create do |topic, transients|
|
|
Fabricate(:post, topic: topic) do
|
|
raw do
|
|
if transients[:content]
|
|
transients[:content]
|
|
else
|
|
sequence(:title) do |i|
|
|
"This is the content of an awesome private template #{i.to_s.rjust(6, "0")}"
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|