Avoid updating ddbb after visiting a page in tests

The extra check to see the voter count has increased was redundant; we
already check the request has finished inside the
`vote_for_poll_via_web` method and we check all three voters are created
in the results table.

Updating the poll so it's in the past after starting the browser might
result in database inconsistencies while running the tests, so we're
using `travel_to` instead.
This commit is contained in:
taitus
2022-09-14 16:17:56 +02:00
committed by Javi Martín
parent 855fedc025
commit b41fbfa52d

View File

@@ -19,22 +19,19 @@ describe "Poll Results" do
login_as user1 login_as user1
vote_for_poll_via_web(poll, question1, "Yes") vote_for_poll_via_web(poll, question1, "Yes")
vote_for_poll_via_web(poll, question2, "Blue") vote_for_poll_via_web(poll, question2, "Blue")
expect(Poll::Voter.count).to eq(1)
logout logout
login_as user2 login_as user2
vote_for_poll_via_web(poll, question1, "Yes") vote_for_poll_via_web(poll, question1, "Yes")
vote_for_poll_via_web(poll, question2, "Green") vote_for_poll_via_web(poll, question2, "Green")
expect(Poll::Voter.count).to eq(2)
logout logout
login_as user3 login_as user3
vote_for_poll_via_web(poll, question1, "No") vote_for_poll_via_web(poll, question1, "No")
vote_for_poll_via_web(poll, question2, "Yellow") vote_for_poll_via_web(poll, question2, "Yellow")
expect(Poll::Voter.count).to eq(3)
logout logout
poll.update!(ends_at: 1.day.ago) travel_to(poll.ends_at + 1.day)
visit results_poll_path(poll) visit results_poll_path(poll)