Simplify adding investments to ballots in specs

This commit is contained in:
Javi Martín
2019-09-28 20:25:32 +02:00
parent c34ebc9a53
commit e2b536e8f8
3 changed files with 21 additions and 14 deletions

View File

@@ -194,12 +194,18 @@ FactoryBot.define do
transient do
voters { [] }
followers { [] }
ballots { [] }
balloters { [] }
end
after(:create) do |investment, evaluator|
evaluator.voters.each { |voter| create(:vote, votable: investment, voter: voter) }
evaluator.followers.each { |follower| create(:follow, followable: investment, user: follower) }
evaluator.ballots.each do |ballot|
create(:budget_ballot_line, investment: investment, ballot: ballot)
end
evaluator.balloters.each do |balloter|
create(:budget_ballot_line, investment: investment, user: balloter)
end
@@ -219,6 +225,14 @@ FactoryBot.define do
factory :budget_ballot, class: "Budget::Ballot" do
association :user, factory: :user
budget
transient { investments { [] } }
after(:create) do |ballot, evaluator|
evaluator.investments.each do |investment|
create(:budget_ballot_line, investment: investment, ballot: ballot)
end
end
end
factory :budget_ballot_line, class: "Budget::Ballot::Line" do