adds proposal factory

This commit is contained in:
kikito
2015-09-12 12:18:23 +02:00
parent 3f7338a6ae
commit 6188e60b5e

View File

@@ -101,6 +101,48 @@ FactoryGirl.define do
end
end
factory :proposal do
sequence(:title) { |n| "Proposal #{n} title" }
description 'Proposal description'
question 'Proposal question'
external_url 'http://decide.madrid.es'
terms_of_service '1'
association :author, factory: :user
trait :hidden do
hidden_at Time.now
end
trait :with_ignored_flag do
ignored_flag_at Time.now
end
trait :with_confirmed_hide do
confirmed_hide_at Time.now
end
trait :flagged do
after :create do |debate|
Flag.flag(FactoryGirl.create(:user), debate)
end
end
trait :with_hot_score do
before(:save) { |d| d.calculate_hot_score }
end
trait :with_confidence_score do
before(:save) { |d| d.calculate_confidence_score }
end
trait :conflictive do
after :create do |debate|
Flag.flag(FactoryGirl.create(:user), debate)
4.times { create(:vote, votable: debate) }
end
end
end
factory :vote do
association :votable, factory: :debate
association :voter, factory: :user