Files
grecia/spec/factories/comments.rb
Javi Martín a727dcc031 Apply Style/SymbolProc rubocop rule
This style is much more concise.
2019-10-26 20:10:32 +02:00

46 lines
1.0 KiB
Ruby

FactoryBot.define do
factory :comment do
association :commentable, factory: :debate
user
sequence(:body) { |n| "Comment body #{n}" }
trait :hidden do
hidden_at { Time.current }
end
trait :with_ignored_flag do
ignored_flag_at { Time.current }
end
trait :with_confirmed_hide do
confirmed_hide_at { Time.current }
end
trait :flagged do
after :create do |debate|
Flag.flag(create(:user), debate)
end
end
trait :with_confidence_score do
before(:save, &:calculate_confidence_score)
end
trait :valuation do
valuation { true }
association :commentable, factory: :budget_investment
before :create do |valuation|
valuator = create(:valuator)
valuation.author = valuator.user
valuation.commentable.valuators << valuator
end
end
transient { voters { [] } }
after(:create) do |comment, evaluator|
evaluator.voters.each { |voter| create(:vote, votable: comment, voter: voter) }
end
end
end