Simplify tests creating poll voters

This commit is contained in:
Javi Martín
2019-03-15 20:31:09 +01:00
parent 4a3115607a
commit 8118926ba7
3 changed files with 10 additions and 13 deletions

View File

@@ -318,10 +318,7 @@ feature "Admin polls" do
unvoted_poll = create(:poll)
voted_poll = create(:poll)
booth_assignment = create(:poll_booth_assignment, poll: voted_poll)
create(:poll_voter, :from_booth, :valid_document,
booth_assignment: booth_assignment,
poll: voted_poll)
create(:poll_voter, :from_booth, :valid_document, poll: voted_poll)
visit admin_poll_results_path(unvoted_poll)

View File

@@ -235,7 +235,7 @@ describe Poll do
user = create(:user, :level_two)
poll = create(:poll)
create(:poll_voter, poll: poll, user: user, origin: "booth")
create(:poll_voter, :from_booth, poll: poll, user: user)
expect(poll.voted_in_booth?(user)).to be
end
@@ -251,7 +251,7 @@ describe Poll do
user = create(:user, :level_two)
poll = create(:poll)
create(:poll_voter, poll: poll, user: user, origin: "web")
create(:poll_voter, :from_web, poll: poll, user: user)
expect(poll.voted_in_booth?(user)).not_to be
end

View File

@@ -76,7 +76,7 @@ describe Poll::Voter do
it "is not valid if the user has voted via web" do
answer = create(:poll_answer)
answer.record_voter_participation("token")
create(:poll_voter, :from_web, user: answer.author, poll: answer.poll)
voter = build(:poll_voter, poll: answer.question.poll, user: answer.author)
expect(voter).not_to be_valid
@@ -113,9 +113,9 @@ describe Poll::Voter do
describe "#web" do
it "returns voters with a web origin" do
voter1 = create(:poll_voter, origin: "web")
voter2 = create(:poll_voter, origin: "web")
voter3 = create(:poll_voter, origin: "booth")
voter1 = create(:poll_voter, :from_web)
voter2 = create(:poll_voter, :from_web)
voter3 = create(:poll_voter, :from_booth)
web_voters = described_class.web
@@ -128,9 +128,9 @@ describe Poll::Voter do
describe "#booth" do
it "returns voters with a booth origin" do
voter1 = create(:poll_voter, origin: "booth")
voter2 = create(:poll_voter, origin: "booth")
voter3 = create(:poll_voter, origin: "web")
voter1 = create(:poll_voter, :from_booth)
voter2 = create(:poll_voter, :from_booth)
voter3 = create(:poll_voter, :from_web)
booth_voters = described_class.booth