Create less headings in budget investment tests

We don't need to create a heading every time we create an investment; we
can use an existing one by default.

Some tests are now much faster and don't fail on Travis due to reaching
Capybara's timeout anymore.
This commit is contained in:
Javi Martín
2019-09-06 20:27:30 +02:00
parent 8bb5462253
commit b5d25134d4
2 changed files with 3 additions and 2 deletions

View File

@@ -83,7 +83,8 @@ FactoryBot.define do
factory :budget_investment, class: "Budget::Investment" do
sequence(:title) { |n| "Budget Investment #{n} title" }
heading { association :budget_heading, budget: budget }
heading { budget&.headings&.reload&.sample || association(:budget_heading, budget: budget) }
association :author, factory: :user
description { "Spend money on this" }
price { 10 }

View File

@@ -87,7 +87,7 @@ describe Budget::Stats do
it "doesn't count nil user ids" do
create(:budget_ballot_line, investment: investment,
ballot: create(:budget_ballot, budget: budget, user: nil, physical: true)
ballot: create(:budget_ballot, budget: budget.reload, user: nil, physical: true)
)
expect(stats.total_participants_vote_phase).to be 0