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.
This commit is contained in:
Javi Martín
2021-04-10 12:51:07 +02:00
parent 804e513c7f
commit 95e38448c0

View File

@@ -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"