From be4cf23a5ca5beacab0f617fc25ba989339b35a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 13 Mar 2025 00:39:28 +0100 Subject: [PATCH] Don't check the database for voters in system tests As mentioned in commits like a586ba806, a7664ad81, 006128da5, b41fbfa52 and c480cdd91, accessing the database after starting the browser with the `visit` method sometimes results in database corruption and failing tests on our CI due to the process running the test accessing the database after the process running the browser has started. In these cases, there's no need to check the database; we're already checking the application behavior that shows that the voters have been correctly created. --- spec/support/common_actions/polls.rb | 2 -- spec/system/budget_polls/voter_spec.rb | 3 --- spec/system/polls/voter_spec.rb | 6 ------ 3 files changed, 11 deletions(-) diff --git a/spec/support/common_actions/polls.rb b/spec/support/common_actions/polls.rb index 92d294038..0340567f6 100644 --- a/spec/support/common_actions/polls.rb +++ b/spec/support/common_actions/polls.rb @@ -18,8 +18,6 @@ module Polls first(:button, "Confirm vote").click expect(page).to have_content "Vote introduced!" - - expect(Poll::Voter.count).to eq(1) end def confirm_phone(code:) diff --git a/spec/system/budget_polls/voter_spec.rb b/spec/system/budget_polls/voter_spec.rb index 6d14c1157..de76c0b90 100644 --- a/spec/system/budget_polls/voter_spec.rb +++ b/spec/system/budget_polls/voter_spec.rb @@ -29,9 +29,6 @@ describe "BudgetPolls", :with_frozen_time do expect(page).to have_content "Vote introduced!" end - expect(Poll::Voter.count).to eq(1) - expect(Poll::Voter.first.origin).to eq("booth") - logout login_as(admin.user) visit admin_poll_recounts_path(poll) diff --git a/spec/system/polls/voter_spec.rb b/spec/system/polls/voter_spec.rb index d44b0b576..1c7991ff8 100644 --- a/spec/system/polls/voter_spec.rb +++ b/spec/system/polls/voter_spec.rb @@ -87,9 +87,6 @@ describe "Voter" do expect(page).to have_content("Vote introduced!") end - expect(Poll::Voter.count).to eq(1) - expect(Poll::Voter.first.origin).to eq("booth") - logout login_as(admin.user) visit admin_poll_recounts_path(poll) @@ -145,7 +142,6 @@ describe "Voter" do scenario "Trying to vote in web and then in booth" do login_as user vote_for_poll_via_web(poll, question, "Yes") - expect(Poll::Voter.count).to eq(1) logout login_through_form_as_officer(officer) @@ -172,7 +168,6 @@ describe "Voter" do end expect(page).to have_content "You have already participated in a physical booth. " \ "You can not participate again." - expect(Poll::Voter.count).to eq(1) logout login_as(admin.user) @@ -211,7 +206,6 @@ describe "Voter" do expect(page).to have_content "You have already participated in a physical booth. " \ "You can not participate again." - expect(Poll::Voter.count).to eq(1) logout login_as(admin.user)