ensl.org/spec/factories/forum.rb
2020-03-22 14:22:10 +02:00

21 lines
483 B
Ruby

FactoryBot.define do
factory :forum do
sequence(:title) { |n| "Forum Title #{n}" }
sequence(:description) { |n| "Forum Description #{n}" }
before :create do |forum|
cat = create(:category, :forums)
forum.category = cat
end
trait :with_content do
after :create do |forum|
(rand(30..100)).times do
topic = build :topic, :with_content
topic.forum = forum
topic.save
end
end
end
end
end