displays appropriate vote info depending on phase

This commit is contained in:
rgarcia
2017-01-13 21:15:08 +01:00
parent 4c818bfcc4
commit 6d71cd985c
8 changed files with 103 additions and 12 deletions

View File

@@ -214,13 +214,19 @@ class Budget
end
def should_show_aside?
(budget.selecting? && !unfeasible?) || (budget.balloting? && feasible?) || budget.on_hold?
(budget.selecting? && !unfeasible?) ||
(budget.balloting? && feasible?) ||
(budget.valuating? && feasible?)
end
def should_show_votes?
budget.selecting?
end
def should_show_vote_count?
budget.valuating?
end
def should_show_ballots?
budget.balloting?
end

View File

@@ -46,7 +46,6 @@
<% unless investment.unfeasible? %>
<% if investment.should_show_votes? %>
<div id="<%= dom_id(investment) %>_votes"
class="small-12 medium-3 column text-center">
<%= render partial: '/budgets/investments/votes', locals: {
@@ -55,9 +54,17 @@
vote_url: namespaced_budget_investment_vote_path(investment, value: 'yes')
} %>
</div>
<% elsif investment.should_show_vote_count? %>
<div id="<%= dom_id(investment) %>_votes"
class="small-12 medium-3 column text-center">
<div class="supports js-participation">
<span class="total-supports no-button">
<%= t("budgets.investments.investment.supports",
count: investment.total_votes) %>
</span>
</div>
</div>
<% elsif investment.should_show_ballots? %>
<div id="<%= dom_id(investment) %>_ballot"
class="small-12 medium-3 column text-center">
<%= render partial: '/budgets/investments/ballot', locals: {
@@ -66,7 +73,6 @@
ballot: ballot
} %>
</div>
<% end %>
<% end %>

View File

@@ -55,11 +55,10 @@
<% if investment.should_show_aside? %>
<aside class="small-12 medium-3 column">
<div class="sidebar-divider"></div>
<h2><%= t("votes.supports") %></h2>
<div class="text-center">
<% if investment.should_show_votes? %>
<div class="sidebar-divider"></div>
<h2><%= t("budgets.investments.show.supports") %></h2>
<div class="text-center">
<div id="<%= dom_id(investment) %>_votes">
<%= render partial: '/budgets/investments/votes', locals: {
investment: investment,
@@ -67,7 +66,20 @@
vote_url: vote_budget_investment_path(investment.budget, investment, value: 'yes')
} %>
</div>
</div>
<% elsif investment.should_show_vote_count? %>
<div class="sidebar-divider"></div>
<h2><%= t("budgets.investments.show.supports") %></h2>
<div class="text-center">
<span class="total-supports">
<%= t("budgets.investments.investment.supports",
count: investment.total_votes) %>
</span>
</div>
<% elsif investment.should_show_ballots? %>
<div class="sidebar-divider"></div>
<h2><%= t("budgets.investments.show.votes") %></h2>
<div class="text-center">
<div id="<%= dom_id(investment) %>_ballot">
<%= render partial: 'ballot', locals: {
investment: investment,
@@ -75,8 +87,8 @@
ballot: ballot,
} %>
</div>
<% end %>
</div>
<% end %>
<div class="sidebar-divider"></div>
<h2><%= t("budgets.investments.show.share") %></h2>

View File

@@ -77,6 +77,8 @@ en:
organization_name_html: 'Organization: <strong>%{name}</strong>'
share: Share
title: Investment project
supports: Supports
votes: Votes
wrong_price_format: Only integer numbers
investment:
title: Investment project

View File

@@ -77,6 +77,8 @@ es:
organization_name_html: 'Organización: <strong>%{name}</strong>'
share: Compartir
title: Propuesta de inversión
supports: Apoyos
votes: Votos
wrong_price_format: Solo puede incluir caracteres numéricos
investment:
title: Propuesta de inversión

View File

@@ -595,6 +595,13 @@ en:
organization: Organizations are not permitted to vote
unfeasible: Unfeasible investment projects can not be supported
not_voting_allowed: Voting phase is closed
budget_investments:
not_logged_in: You must %{signin} or %{signup} to continue.
not_verified: Only verified users can vote on proposals; %{verify_account}.
organization: Organizations are not permitted to vote
unfeasible: Unfeasible investment projects can not be supported
not_voting_allowed: Voting phase is closed
different_heading_assigned: You can only support proposals in one district
welcome:
debates:
description: For meeting, discussing and sharing the things that matter to us in our city.

View File

@@ -595,6 +595,13 @@ es:
organization: Las organizaciones no pueden votar.
unfeasible: No se pueden votar propuestas inviables.
not_voting_allowed: El periodo de votación está cerrado.
budget_investments:
not_logged_in: Necesitas %{signin} o %{signup} para continuar.
not_verified: Las propuestas de inversión sólo pueden ser apoyadas por usuarios verificados, %{verify_account}.
organization: Las organizaciones no pueden votar.
unfeasible: No se pueden votar propuestas inviables.
not_voting_allowed: El periodo de votación está cerrado.
different_heading_assigned: Sólo puedes apoyar propuestas en un distrito
welcome:
debates:
description: Encontrarnos, debatir y compartir lo que nos parece importante en nuestra ciudad.

View File

@@ -345,6 +345,46 @@ feature 'Budget Investments' do
end
end
scenario "Sidebar in show should display support text" do
investment = create(:budget_investment, budget: budget)
visit budget_investment_path(budget, investment)
within("aside") do
expect(page).to have_content "Supports"
end
end
end
context "Evaluating Phase" do
background do
budget.update(phase: "valuating")
end
scenario "Sidebar in show should display supports text and supports" do
investment = create(:budget_investment, :selected, budget: budget)
create(:vote, votable: investment)
visit budget_investment_path(budget, investment)
within("aside") do
expect(page).to have_content "Supports"
expect(page).to have_content "1 support"
end
end
scenario "Index should display supports" do
investment = create(:budget_investment, :selected, budget: budget, heading: heading)
create(:vote, votable: investment)
visit budget_investments_path(budget, heading_id: heading.id)
within("#budget_investment_#{investment.id}") do
expect(page).to have_content "1 support"
end
end
end
context "Balloting Phase" do
@@ -407,6 +447,15 @@ feature 'Budget Investments' do
expect(page).to have_content "€10,000"
end
scenario "Sidebar in show should display vote text" do
investment = create(:budget_investment, :selected, budget: budget)
visit budget_investment_path(budget, investment)
within("aside") do
expect(page).to have_content "Votes"
end
end
scenario "Confirm", :js do
budget.update(phase: 'balloting')
user = create(:user, :level_two)