From 9edabb5bf4e43d033368ba717c4c0cac2c924140 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 29 Jan 2019 16:17:42 +0100 Subject: [PATCH] Fix links on budgets index page --- app/views/budgets/index.html.erb | 6 ++--- spec/features/budgets/budgets_spec.rb | 38 ++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index 9b0dd66f9..2d7e82eaa 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -96,15 +96,15 @@

<% show_links = show_links_to_budget_investments(current_budget) %> <% if show_links %> - <%= link_to budget_investments_path(current_budget.id) do %> + <%= link_to budget_url(current_budget) do %> <%= t("budgets.index.investment_proyects") %> <% end %>
<% end %> - <%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unfeasible') do %> + <%= link_to budget_url(current_budget, filter: 'unfeasible') do %> <%= t("budgets.index.unfeasible_investment_proyects") %> <% end %>
<% if show_links %> - <%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unselected') do %> + <%= link_to budget_url(current_budget, filter: 'unselected') do %> <%= t("budgets.index.not_selected_investment_proyects") %> <% end %> <% end %> diff --git a/spec/features/budgets/budgets_spec.rb b/spec/features/budgets/budgets_spec.rb index cd4c5615d..b3fa3bee3 100644 --- a/spec/features/budgets/budgets_spec.rb +++ b/spec/features/budgets/budgets_spec.rb @@ -60,22 +60,46 @@ feature 'Budgets' do end end - scenario 'Show informing index without links' do - budget.update_attributes(phase: 'informing') + scenario "Show informing index without links" do + budget.update_attributes(phase: "informing") group = create(:budget_group, budget: budget) - heading = create(:budget_heading, group: group, name: 'Health') + heading = create(:budget_heading, group: group) visit budgets_path - within('#budget_info') do - expect(page).not_to have_link("Health €1,000,000") - expect(page).to have_content("Health €1,000,000") + within("#budget_info") do + expect(page).not_to have_link "#{heading.name} €1,000,000" + expect(page).to have_content "#{heading.name} €1,000,000" expect(page).not_to have_link("List of all investment projects") expect(page).not_to have_link("List of all unfeasible investment projects") expect(page).not_to have_link("List of all investment projects not selected for balloting") - expect(page).not_to have_css('div#map') + expect(page).not_to have_css("div.map") + end + end + + scenario "Show finished index without heading links" do + budget.update_attributes(phase: "finished") + group = create(:budget_group, budget: budget) + heading = create(:budget_heading, group: group) + + visit budgets_path + + within("#budget_info") do + expect(page).not_to have_link "#{heading.name} €1,000,000" + expect(page).to have_content "#{heading.name} €1,000,000" + + expect(page).to have_link "List of all investment projects", + href: budget_url(budget) + + expect(page).to have_link "List of all unfeasible investment projects", + href: budget_url(budget, filter: "unfeasible") + + expect(page).to have_link "List of all investment projects not selected for balloting", + href: budget_url(budget, filter: "unselected") + + expect(page).to have_css("div.map") end end