From b41fbfa52d5b4e71e49e749d551a04807b161032 Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 14 Sep 2022 16:17:56 +0200 Subject: [PATCH] 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. --- spec/system/polls/results_spec.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec/system/polls/results_spec.rb b/spec/system/polls/results_spec.rb index 057519922..2fbfe82a1 100644 --- a/spec/system/polls/results_spec.rb +++ b/spec/system/polls/results_spec.rb @@ -19,22 +19,19 @@ describe "Poll Results" do login_as user1 vote_for_poll_via_web(poll, question1, "Yes") vote_for_poll_via_web(poll, question2, "Blue") - expect(Poll::Voter.count).to eq(1) logout login_as user2 vote_for_poll_via_web(poll, question1, "Yes") vote_for_poll_via_web(poll, question2, "Green") - expect(Poll::Voter.count).to eq(2) logout login_as user3 vote_for_poll_via_web(poll, question1, "No") vote_for_poll_via_web(poll, question2, "Yellow") - expect(Poll::Voter.count).to eq(3) logout - poll.update!(ends_at: 1.day.ago) + travel_to(poll.ends_at + 1.day) visit results_poll_path(poll)