ensl.org/spec/factories/forum.rb

22 lines
483 B
Ruby
Raw Normal View History

FactoryBot.define do
2015-08-20 14:48:19 +00:00
factory :forum do
sequence(:title) { |n| "Forum Title #{n}" }
sequence(:description) { |n| "Forum Description #{n}" }
2020-03-22 12:22:10 +00:00
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
2015-08-20 14:48:19 +00:00
end
2015-08-20 15:35:25 +00:00
end