From 3345dd67d9668402a1ab90b395f47d0284a40c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 15 Apr 2021 18:55:00 +0200 Subject: [PATCH] Remove unnecessary `in_browser` clause We only need to define one `in_browser`, which is the one opening the session as an administrator. This change is done to simplify the code, although there's a small chance it might also make the test stop failing in our CI. Sometimes in our CI the first `visit` in the `in_browser(:admin)` block fails for unknown reasons, rendering a blank page. --- spec/system/budgets/ballots_spec.rb | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/spec/system/budgets/ballots_spec.rb b/spec/system/budgets/ballots_spec.rb index 1a9c161f8..535192c8d 100644 --- a/spec/system/budgets/ballots_spec.rb +++ b/spec/system/budgets/ballots_spec.rb @@ -629,12 +629,10 @@ describe "Ballots" do investment1 = create(:budget_investment, :selected, heading: new_york, price: 10000) admin_user = create(:administrator).user - in_browser(:user) do - login_as user - visit budget_investments_path(budget, heading_id: new_york) + login_as user + visit budget_investments_path(budget, heading_id: new_york) - expect(page).to have_css(".in-favor a") - end + expect(page).to have_css(".in-favor a") in_browser(:admin) do login_as admin_user @@ -649,18 +647,16 @@ describe "Ballots" do end end - in_browser(:user) do - within("#budget_investment_#{investment1.id}") do - find(".in-favor a").click + within("#budget_investment_#{investment1.id}") do + find(".in-favor a").click - expect(page).not_to have_content "Remove" - expect(page).not_to have_selector(".participation-not-allowed") + expect(page).not_to have_content "Remove" + expect(page).not_to have_selector(".participation-not-allowed") - hover_over_ballot + hover_over_ballot - expect(page).to have_selector(".participation-not-allowed") - expect(page).to have_selector(".in-favor a", obscured: true) - end + expect(page).to have_selector(".participation-not-allowed") + expect(page).to have_selector(".in-favor a", obscured: true) end end