Files
grecia/spec/factories/classifications.rb
Javi Martín b8fbd6347b Use acts_as_taggable for investment valuation tags
We were manually doing the same thing, generating inconsistent results,
since the method `valuation_tag_list` was using the `valuation` context,
when actually the expected behavior would be to use the `valuation_tag`
context.
2019-11-01 17:12:31 +01:00

51 lines
1.1 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 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