Display message in budget's index when there are no budgets
When there are no budgets we were seeing an exception in the budgets’ index There are two parts to take into account here: 1) Making sure there is a current_budget present, otherwise we display the “no budgets” message 2) The map helper is called from the controller, so we need to make sure current_budget is present there too Note: We could have added a bunch of `try` statements in the budgets’s index, instead of using a conditional, however there are quite a few `current_budget` calls so it seems more appropriate to use a conditional
This commit is contained in:
@@ -65,6 +65,7 @@ module BudgetsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def current_budget_map_locations
|
def current_budget_map_locations
|
||||||
|
return unless current_budget.present?
|
||||||
MapLocation.where(investment_id: current_budget.investments).map { |l| l.json_data }
|
MapLocation.where(investment_id: current_budget.investments).map { |l| l.json_data }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
<%= render "shared/canonical", href: budgets_url %>
|
<%= render "shared/canonical", href: budgets_url %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div id="budget_heading" class="expanded budget no-margin-top">
|
<% if current_budget.present? %>
|
||||||
|
<div id="budget_heading" class="expanded budget no-margin-top">
|
||||||
<div class="row" data-equalizer data-equalizer-on="medium">
|
<div class="row" data-equalizer data-equalizer-on="medium">
|
||||||
<div class="small-12 medium-9 column padding" data-equalizer-watch>
|
<div class="small-12 medium-9 column padding" data-equalizer-watch>
|
||||||
|
|
||||||
@@ -55,9 +56,9 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="budget_info" class="budget-info">
|
<div id="budget_info" class="budget-info">
|
||||||
<div class="row margin-top">
|
<div class="row margin-top">
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
|
|
||||||
@@ -167,4 +168,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<%= t("budgets.index.empty_budgets") %>
|
||||||
|
<% end %>
|
||||||
@@ -41,6 +41,7 @@ en:
|
|||||||
finished: Finished budget
|
finished: Finished budget
|
||||||
index:
|
index:
|
||||||
title: Participatory budgets
|
title: Participatory budgets
|
||||||
|
empty_budgets: There are no budgets
|
||||||
section_header:
|
section_header:
|
||||||
icon_alt: Participatory budgets icon
|
icon_alt: Participatory budgets icon
|
||||||
title: Participatory budgets
|
title: Participatory budgets
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ es:
|
|||||||
finished: Resultados
|
finished: Resultados
|
||||||
index:
|
index:
|
||||||
title: Presupuestos participativos
|
title: Presupuestos participativos
|
||||||
|
empty_budgets: No hay presupuestos participativos
|
||||||
section_header:
|
section_header:
|
||||||
icon_alt: Icono de Presupuestos participativos
|
icon_alt: Icono de Presupuestos participativos
|
||||||
title: Presupuestos participativos
|
title: Presupuestos participativos
|
||||||
|
|||||||
@@ -117,6 +117,13 @@ feature 'Budgets' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "No budgets" do
|
||||||
|
Budget.destroy_all
|
||||||
|
|
||||||
|
visit budgets_path
|
||||||
|
|
||||||
|
expect(page).to have_content "There are no budgets"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Index shows only published phases' do
|
scenario 'Index shows only published phases' do
|
||||||
|
|||||||
Reference in New Issue
Block a user