mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
20 lines
409 B
Ruby
20 lines
409 B
Ruby
FactoryBot.define do
|
|
factory :topic do
|
|
sequence(:title) { |n| "Topic Title #{n}" }
|
|
forum
|
|
user
|
|
before(:create) do |topic|
|
|
topic.first_post = "My first post on the topic"
|
|
end
|
|
|
|
trait :with_content do
|
|
after :create do |topic|
|
|
(rand(1..30)).times do
|
|
post = build :post
|
|
post.topic = topic
|
|
post.save
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|