From 006128da57fce928b3418f89b3216d94b73f73d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 18 Nov 2021 14:58:44 +0100 Subject: [PATCH] Query the database before a visit in campaigns test This test was failing sometimes. One possible cause (although it might not be the only one) is we were querying the database with `Campaing.last` after starting the process running the browser with a `visit`. In the past doing so has resulted in database inconsistencies while running the tests. Since after running the test more than 1500 times we weren't able to reproduce the failure, it's possible that this change doesn't fix the issue which caused the test to fail, but in the worst case scenario we reduce the number of possible reasons why it fails. --- spec/system/campaigns_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/system/campaigns_spec.rb b/spec/system/campaigns_spec.rb index 744fa941e..7fe4b6afe 100644 --- a/spec/system/campaigns_spec.rb +++ b/spec/system/campaigns_spec.rb @@ -20,8 +20,10 @@ describe "Email campaigns", :admin do end scenario "Do not track erroneous track_ids" do + invalid_id = Campaign.last.id + 1 + visit root_path(track_id: campaign1.track_id) - visit root_path(track_id: Campaign.last.id + 1) + visit root_path(track_id: invalid_id) visit admin_stats_path