From 6cfb862553b69d0cb94477189388880bbfe84838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 15 Mar 2021 13:55:02 +0100 Subject: [PATCH] Remove unneeded turbolinks: false link parameter It was added because a test failed without turbolinks. However, writing the test so it doesn't update the database at the same time the browser is doing a request also solves the problem and makes the test more robust. --- app/views/budgets/groups/show.html.erb | 3 +- app/views/budgets/show.html.erb | 3 +- spec/system/budgets/ballots_spec.rb | 38 ++++++++++++++++++-------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/app/views/budgets/groups/show.html.erb b/app/views/budgets/groups/show.html.erb index d8741f6eb..81a797797 100644 --- a/app/views/budgets/groups/show.html.erb +++ b/app/views/budgets/groups/show.html.erb @@ -35,8 +35,7 @@ class="<%= css_for_ballot_heading(heading) %>"> <%= link_to heading.name, budget_investments_path(heading_id: heading.id, - filter: @current_filter), - data: { turbolinks: false } %>
+ filter: @current_filter) %>
<% end %> diff --git a/app/views/budgets/show.html.erb b/app/views/budgets/show.html.erb index f7e6617e0..73f444bec 100644 --- a/app/views/budgets/show.html.erb +++ b/app/views/budgets/show.html.erb @@ -35,8 +35,7 @@ <%= link_to group.name, budget_investments_path(@budget, heading_id: group.headings.first.id, - filter: @current_filter), - data: { turbolinks: false } %> + filter: @current_filter) %> <% else %> <%= link_to group.name, budget_group_path(@budget, group, diff --git a/spec/system/budgets/ballots_spec.rb b/spec/system/budgets/ballots_spec.rb index 3db1a4cdf..a6c737770 100644 --- a/spec/system/budgets/ballots_spec.rb +++ b/spec/system/budgets/ballots_spec.rb @@ -1,4 +1,5 @@ require "rails_helper" +require "sessions_helper" describe "Ballots" do let(:user) { create(:user, :level_two) } @@ -679,23 +680,36 @@ describe "Ballots" do scenario "Edge case voting a non-elegible investment", :js do investment1 = create(:budget_investment, :selected, heading: new_york, price: 10000) - login_as(user) - visit budget_path(budget) - click_link "States" - click_link "New York" + in_browser(:user) do + login_as user + visit budget_path(budget) + click_link "States" + click_link "New York" - new_york.update!(price: 10) + expect(page).to have_css(".in-favor a") + end - within("#budget_investment_#{investment1.id}") do - find(".in-favor a").click + in_browser(:admin) do + login_as create(:administrator).user + visit edit_admin_budget_group_heading_path(budget, states, new_york) + fill_in "Amount", with: 10 + click_button "Save heading" - expect(page).not_to have_content "Remove" - expect(page).not_to have_selector(".participation-not-allowed") + expect(page).to have_content "Heading updated successfully" + end - hover_over_ballot + in_browser(:user) do + within("#budget_investment_#{investment1.id}") do + find(".in-favor a").click - expect(page).to have_selector(".participation-not-allowed") - expect(page).to have_selector(".in-favor a", obscured: true) + expect(page).not_to have_content "Remove" + expect(page).not_to have_selector(".participation-not-allowed") + + hover_over_ballot + + expect(page).to have_selector(".participation-not-allowed") + expect(page).to have_selector(".in-favor a", obscured: true) + end end end