Simplify creating ballot lines in specs
This commit is contained in:
@@ -1060,10 +1060,7 @@ describe Budget::Investment do
|
||||
it "stores the votes for a reclassified investment" do
|
||||
investment = create(:budget_investment, :selected, heading: heading1)
|
||||
|
||||
3.times do
|
||||
ballot = create(:budget_ballot, budget: budget)
|
||||
ballot.investments << investment
|
||||
end
|
||||
3.times { create(:user, ballot_lines: [investment]) }
|
||||
|
||||
expect(investment.ballot_lines_count).to eq(3)
|
||||
|
||||
@@ -1084,10 +1081,7 @@ describe Budget::Investment do
|
||||
it "removes votes from invesment" do
|
||||
investment = create(:budget_investment, :selected, heading: heading1)
|
||||
|
||||
3.times do
|
||||
ballot = create(:budget_ballot, budget: budget)
|
||||
ballot.investments << investment
|
||||
end
|
||||
3.times { create(:user, ballot_lines: [investment]) }
|
||||
|
||||
expect(investment.ballot_lines_count).to eq(3)
|
||||
|
||||
@@ -1105,10 +1099,7 @@ describe Budget::Investment do
|
||||
it "stores reclassfied votes and removes actual votes if an investment has been reclassified" do
|
||||
investment = create(:budget_investment, :selected, heading: heading1)
|
||||
|
||||
3.times do
|
||||
ballot = create(:budget_ballot, budget: budget)
|
||||
ballot.investments << investment
|
||||
end
|
||||
3.times { create(:user, ballot_lines: [investment]) }
|
||||
|
||||
expect(investment.ballot_lines_count).to eq(3)
|
||||
|
||||
@@ -1123,10 +1114,7 @@ describe Budget::Investment do
|
||||
it "does not store reclassified votes nor remove actual votes if the investment has not been reclassifed" do
|
||||
investment = create(:budget_investment, :selected, heading: heading1)
|
||||
|
||||
3.times do
|
||||
ballot = create(:budget_ballot, budget: budget)
|
||||
ballot.investments << investment
|
||||
end
|
||||
3.times { create(:user, ballot_lines: [investment]) }
|
||||
|
||||
expect(investment.ballot_lines_count).to eq(3)
|
||||
|
||||
|
||||
@@ -9,17 +9,14 @@ describe Budget::Stats do
|
||||
let!(:author) { investment.author }
|
||||
let!(:author_and_voter) { create(:user, :hidden, votables: [investment]) }
|
||||
let!(:voter) { create(:user, votables: [investment]) }
|
||||
let!(:voter_and_balloter) { create(:user, votables: [investment]) }
|
||||
let!(:balloter) { create(:user, :hidden) }
|
||||
let!(:voter_and_balloter) { create(:user, votables: [investment], ballot_lines: [investment]) }
|
||||
let!(:balloter) { create(:user, :hidden, ballot_lines: [investment]) }
|
||||
let!(:poll_balloter) { create(:user, :level_two) }
|
||||
let!(:non_participant) { create(:user, :level_two) }
|
||||
|
||||
before do
|
||||
create(:budget_investment, :selected, budget: budget, author: author_and_voter)
|
||||
|
||||
create(:budget_ballot_line, investment: investment, user: balloter)
|
||||
create(:budget_ballot_line, investment: investment, user: voter_and_balloter)
|
||||
|
||||
create(:poll_voter, :from_booth, user: poll_balloter, budget: budget)
|
||||
|
||||
create(:poll_voter, :from_booth, user: non_participant, budget: create(:budget))
|
||||
@@ -42,8 +39,7 @@ describe Budget::Stats do
|
||||
end
|
||||
|
||||
it "counts a user who is voter and balloter" do
|
||||
voter_and_balloter = create(:user, votables: [investment])
|
||||
create(:budget_ballot_line, investment: investment, user: voter_and_balloter)
|
||||
create(:user, votables: [investment], ballot_lines: [investment])
|
||||
|
||||
expect(stats.total_participants_support_phase).to be 1
|
||||
end
|
||||
@@ -58,8 +54,7 @@ describe Budget::Stats do
|
||||
end
|
||||
|
||||
it "counts a user who is voter and balloter" do
|
||||
voter_and_balloter = create(:user, votables: [investment])
|
||||
create(:budget_ballot_line, investment: investment, user: voter_and_balloter)
|
||||
create(:user, votables: [investment], ballot_lines: [investment])
|
||||
|
||||
expect(stats.total_participants_vote_phase).to be 1
|
||||
end
|
||||
@@ -72,8 +67,7 @@ describe Budget::Stats do
|
||||
end
|
||||
|
||||
it "counts once a user who is balloter and poll balloter" do
|
||||
poller_and_balloter = create(:user, :level_two)
|
||||
create(:budget_ballot_line, investment: investment, user: poller_and_balloter)
|
||||
poller_and_balloter = create(:user, :level_two, ballot_lines: [investment])
|
||||
create(:poll_voter, :from_booth, user: poller_and_balloter, budget: budget)
|
||||
|
||||
expect(stats.total_participants_vote_phase).to be 1
|
||||
|
||||
Reference in New Issue
Block a user