Files
nairobi/spec/factories/classifications.rb
2019-10-20 15:03:05 +02:00

51 lines
1.2 KiB
Ruby

FactoryBot.define do
factory :tag do
sequence(:name) { |n| "Tag #{n} name" }
trait :category do
kind { "category" }
end
trait :milestone do
kind { "milestone" }
end
transient { taggables { [] } }
after(:create) do |tag, evaluator|
evaluator.taggables.each do |taggable|
create(:tagging, tag: tag, taggable: taggable)
end
end
end
factory :tagging, class: "ActsAsTaggableOn::Tagging" do
context { "tags" }
association :taggable, factory: :proposal
tag
end
factory :topic do
sequence(:title) { |n| "Topic title #{n}" }
sequence(:description) { |n| "Description as comment #{n}" }
association :author, factory: :user
trait :with_community do
community { create(:proposal).community }
end
factory :topic_with_community, traits: [:with_community]
end
factory :related_content do
association :author, factory: :user
association :parent_relationable, factory: [:proposal, :debate].sample
association :child_relationable, factory: [:proposal, :debate].sample
end
factory :related_content_score do
association :user
association :related_content
end
end