Show message for headings without winner investments

This commit is contained in:
Angel Perez
2018-07-11 12:39:34 -04:00
committed by Javi Martín
parent 5114792941
commit 62b99f01bc
4 changed files with 50 additions and 25 deletions

View File

@@ -2,32 +2,38 @@
<h4 id="<%= heading.name.parameterize %>">
<%= heading.name %>
</h4>
<div class="row" data-equalizer-on="medium" data-equalizer>
<% winner_investments(heading).each do |investment| %>
<div class="small-12 medium-6 large-4 column end margin-bottom">
<div class="budget-execution">
<%= 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? %>
<div class="row" data-equalizer-on="medium" data-equalizer>
<% winner_investments(heading).each do |investment| %>
<div class="small-12 medium-6 large-4 column end margin-bottom">
<div class="budget-execution">
<%= 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 %>
<div class="budget-execution-info">
<div class="budget-execution-content">
<h5><%= investment.title %></h5>
<span class="author"><%= investment.author.name %></span>
<div class="budget-execution-info">
<div class="budget-execution-content">
<h5><%= investment.title %></h5>
<span class="author"><%= investment.author.name %></span>
</div>
<p class="price margin-top text-center">
<strong><%= investment.formatted_price %></strong>
</p>
</div>
<p class="price margin-top text-center">
<strong><%= investment.formatted_price %></strong>
</p>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
<% end %>
</div>
<% else %>
<div class="callout primary clear">
<%= t("budgets.executions.no_winner_investments") %>
</div>
<% end %>
<% end %>

View File

@@ -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"

View File

@@ -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"

View File

@@ -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)