From 95e38448c045b631c2124b1c2664a5afe80bbf02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 10 Apr 2021 12:51:07 +0200 Subject: [PATCH] Reduce number of requests in dashboard poll tests Just like we did in commit 0ec8878db, we remove the useless initial request in the `before` filter since most tests started by visiting a different URL. We also reduce the risk of database inconsistency which comes with setting up the database after the browser has been started. --- spec/system/dashboard/polls_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/system/dashboard/polls_spec.rb b/spec/system/dashboard/polls_spec.rb index d1280c987..367cc1c08 100644 --- a/spec/system/dashboard/polls_spec.rb +++ b/spec/system/dashboard/polls_spec.rb @@ -3,16 +3,16 @@ require "rails_helper" describe "Polls" do let!(:proposal) { create(:proposal, :draft) } - before do - login_as(proposal.author) - visit proposal_dashboard_path(proposal) - end + before { login_as(proposal.author) } scenario "Has a link to polls feature" do + visit proposal_dashboard_path(proposal) + expect(page).to have_link("Polls") end scenario "Create a poll" do + visit proposal_dashboard_path(proposal) click_link "Polls" click_link "Create poll" @@ -80,6 +80,7 @@ describe "Polls" do end scenario "Create a poll redirects back to form when invalid data" do + visit proposal_dashboard_path(proposal) click_link "Polls" click_link "Create poll"