diff --git a/app/views/budgets/executions/_investments.html.erb b/app/views/budgets/executions/_investments.html.erb index 0c96a58e7..b04639a50 100644 --- a/app/views/budgets/executions/_investments.html.erb +++ b/app/views/budgets/executions/_investments.html.erb @@ -2,32 +2,38 @@

<%= heading.name %>

-
- <% winner_investments(heading).each do |investment| %> -
-
- <%= link_to budget_investment_path(@budget, investment, anchor: "tab-milestones"), data: { 'equalizer-watch': true } do %> - <% investment.milestones.order(publication_date: :desc).limit(1).each do |milestone| %> - <% if milestone.image.present? %> - <%= image_tag milestone.image_url(:large), alt: milestone.image.title %> - <% elsif investment.image.present? %> - <%= image_tag investment.image_url(:thumb), alt: investment.image.title %> - <% else %> - <%= image_tag Rails.root.join('/budget_execution_no_image.jpg'), alt: investment.title %> + <% if winner_investments(heading).any? %> +
+ <% winner_investments(heading).each do |investment| %> +
+
+ <%= link_to budget_investment_path(@budget, investment, anchor: "tab-milestones"), data: { 'equalizer-watch': true } do %> + <% investment.milestones.order(publication_date: :desc).limit(1).each do |milestone| %> + <% if milestone.image.present? %> + <%= image_tag milestone.image_url(:large), alt: milestone.image.title %> + <% elsif investment.image.present? %> + <%= image_tag investment.image_url(:thumb), alt: investment.image.title %> + <% else %> + <%= image_tag Rails.root.join('/budget_execution_no_image.jpg'), alt: investment.title %> + <% end %> <% end %> - <% end %> -
-
-
<%= investment.title %>
- <%= investment.author.name %> +
+
+
<%= investment.title %>
+ <%= investment.author.name %> +
+

+ <%= investment.formatted_price %> +

-

- <%= investment.formatted_price %> -

-
- <% end %> + <% end %> +
-
- <% end %> -
+ <% end %> +
+ <% else %> +
+ <%= t("budgets.executions.no_winner_investments") %> +
+ <% end %> <% end %> diff --git a/config/locales/en/budgets.yml b/config/locales/en/budgets.yml index 37d364305..b342aaf86 100644 --- a/config/locales/en/budgets.yml +++ b/config/locales/en/budgets.yml @@ -179,6 +179,7 @@ en: page_title: "%{budget} - Milestones" heading: "Participatory budget Milestones" heading_selection_title: "By district" + no_winner_investments: "No winner investments for this heading" filters: label: "Project's current state" all: "All" diff --git a/config/locales/es/budgets.yml b/config/locales/es/budgets.yml index 9547c235a..7f1e03914 100644 --- a/config/locales/es/budgets.yml +++ b/config/locales/es/budgets.yml @@ -179,6 +179,7 @@ es: page_title: "%{budget} - Seguimiento de proyectos" heading: "Seguimiento de proyectos" heading_selection_title: "Ámbito de actuación" + no_winner_investments: "No hay proyectos de gasto ganadores para esta partida" filters: label: "Estado actual del proyecto" all: "Todos" diff --git a/spec/features/budgets/executions_spec.rb b/spec/features/budgets/executions_spec.rb index 2dd9b5954..6c3b6b6b1 100644 --- a/spec/features/budgets/executions_spec.rb +++ b/spec/features/budgets/executions_spec.rb @@ -27,6 +27,23 @@ feature 'Executions' do expect(page).not_to have_content(investment4.title) end + scenario 'render a message for headings without winner investments' do + empty_group = create(:budget_group, budget: budget) + empty_heading = create(:budget_heading, group: empty_group, price: 1000) + + visit budget_path(budget) + click_link 'See results' + + expect(page).to have_content(heading.name) + expect(page).to have_content(empty_heading.name) + + click_link 'Milestones' + click_link "#{empty_heading.name}" + + expect(page).to have_content('No winner investments for this heading') + end + + context 'Images' do scenario 'renders milestone image if available' do milestone1 = create(:budget_investment_milestone, investment: investment1)