displays appropriate vote info depending on phase
This commit is contained in:
@@ -214,13 +214,19 @@ class Budget
|
|||||||
end
|
end
|
||||||
|
|
||||||
def should_show_aside?
|
def should_show_aside?
|
||||||
(budget.selecting? && !unfeasible?) || (budget.balloting? && feasible?) || budget.on_hold?
|
(budget.selecting? && !unfeasible?) ||
|
||||||
|
(budget.balloting? && feasible?) ||
|
||||||
|
(budget.valuating? && feasible?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def should_show_votes?
|
def should_show_votes?
|
||||||
budget.selecting?
|
budget.selecting?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def should_show_vote_count?
|
||||||
|
budget.valuating?
|
||||||
|
end
|
||||||
|
|
||||||
def should_show_ballots?
|
def should_show_ballots?
|
||||||
budget.balloting?
|
budget.balloting?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -46,7 +46,6 @@
|
|||||||
<% unless investment.unfeasible? %>
|
<% unless investment.unfeasible? %>
|
||||||
|
|
||||||
<% if investment.should_show_votes? %>
|
<% if investment.should_show_votes? %>
|
||||||
|
|
||||||
<div id="<%= dom_id(investment) %>_votes"
|
<div id="<%= dom_id(investment) %>_votes"
|
||||||
class="small-12 medium-3 column text-center">
|
class="small-12 medium-3 column text-center">
|
||||||
<%= render partial: '/budgets/investments/votes', locals: {
|
<%= render partial: '/budgets/investments/votes', locals: {
|
||||||
@@ -55,9 +54,17 @@
|
|||||||
vote_url: namespaced_budget_investment_vote_path(investment, value: 'yes')
|
vote_url: namespaced_budget_investment_vote_path(investment, value: 'yes')
|
||||||
} %>
|
} %>
|
||||||
</div>
|
</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? %>
|
<% elsif investment.should_show_ballots? %>
|
||||||
|
|
||||||
<div id="<%= dom_id(investment) %>_ballot"
|
<div id="<%= dom_id(investment) %>_ballot"
|
||||||
class="small-12 medium-3 column text-center">
|
class="small-12 medium-3 column text-center">
|
||||||
<%= render partial: '/budgets/investments/ballot', locals: {
|
<%= render partial: '/budgets/investments/ballot', locals: {
|
||||||
@@ -66,7 +73,6 @@
|
|||||||
ballot: ballot
|
ballot: ballot
|
||||||
} %>
|
} %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -55,11 +55,10 @@
|
|||||||
|
|
||||||
<% if investment.should_show_aside? %>
|
<% if investment.should_show_aside? %>
|
||||||
<aside class="small-12 medium-3 column">
|
<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? %>
|
<% 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">
|
<div id="<%= dom_id(investment) %>_votes">
|
||||||
<%= render partial: '/budgets/investments/votes', locals: {
|
<%= render partial: '/budgets/investments/votes', locals: {
|
||||||
investment: investment,
|
investment: investment,
|
||||||
@@ -67,7 +66,20 @@
|
|||||||
vote_url: vote_budget_investment_path(investment.budget, investment, value: 'yes')
|
vote_url: vote_budget_investment_path(investment.budget, investment, value: 'yes')
|
||||||
} %>
|
} %>
|
||||||
</div>
|
</div>
|
||||||
<% elsif investment.should_show_ballots? %>
|
</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">
|
<div id="<%= dom_id(investment) %>_ballot">
|
||||||
<%= render partial: 'ballot', locals: {
|
<%= render partial: 'ballot', locals: {
|
||||||
investment: investment,
|
investment: investment,
|
||||||
@@ -75,8 +87,8 @@
|
|||||||
ballot: ballot,
|
ballot: ballot,
|
||||||
} %>
|
} %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
</div>
|
||||||
</div>
|
<% end %>
|
||||||
|
|
||||||
<div class="sidebar-divider"></div>
|
<div class="sidebar-divider"></div>
|
||||||
<h2><%= t("budgets.investments.show.share") %></h2>
|
<h2><%= t("budgets.investments.show.share") %></h2>
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ en:
|
|||||||
organization_name_html: 'Organization: <strong>%{name}</strong>'
|
organization_name_html: 'Organization: <strong>%{name}</strong>'
|
||||||
share: Share
|
share: Share
|
||||||
title: Investment project
|
title: Investment project
|
||||||
|
supports: Supports
|
||||||
|
votes: Votes
|
||||||
wrong_price_format: Only integer numbers
|
wrong_price_format: Only integer numbers
|
||||||
investment:
|
investment:
|
||||||
title: Investment project
|
title: Investment project
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ es:
|
|||||||
organization_name_html: 'Organización: <strong>%{name}</strong>'
|
organization_name_html: 'Organización: <strong>%{name}</strong>'
|
||||||
share: Compartir
|
share: Compartir
|
||||||
title: Propuesta de inversión
|
title: Propuesta de inversión
|
||||||
|
supports: Apoyos
|
||||||
|
votes: Votos
|
||||||
wrong_price_format: Solo puede incluir caracteres numéricos
|
wrong_price_format: Solo puede incluir caracteres numéricos
|
||||||
investment:
|
investment:
|
||||||
title: Propuesta de inversión
|
title: Propuesta de inversión
|
||||||
|
|||||||
@@ -595,6 +595,13 @@ en:
|
|||||||
organization: Organizations are not permitted to vote
|
organization: Organizations are not permitted to vote
|
||||||
unfeasible: Unfeasible investment projects can not be supported
|
unfeasible: Unfeasible investment projects can not be supported
|
||||||
not_voting_allowed: Voting phase is closed
|
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:
|
welcome:
|
||||||
debates:
|
debates:
|
||||||
description: For meeting, discussing and sharing the things that matter to us in our city.
|
description: For meeting, discussing and sharing the things that matter to us in our city.
|
||||||
|
|||||||
@@ -595,6 +595,13 @@ es:
|
|||||||
organization: Las organizaciones no pueden votar.
|
organization: Las organizaciones no pueden votar.
|
||||||
unfeasible: No se pueden votar propuestas inviables.
|
unfeasible: No se pueden votar propuestas inviables.
|
||||||
not_voting_allowed: El periodo de votación está cerrado.
|
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:
|
welcome:
|
||||||
debates:
|
debates:
|
||||||
description: Encontrarnos, debatir y compartir lo que nos parece importante en nuestra ciudad.
|
description: Encontrarnos, debatir y compartir lo que nos parece importante en nuestra ciudad.
|
||||||
|
|||||||
@@ -345,6 +345,46 @@ feature 'Budget Investments' do
|
|||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
context "Balloting Phase" do
|
context "Balloting Phase" do
|
||||||
@@ -407,6 +447,15 @@ feature 'Budget Investments' do
|
|||||||
expect(page).to have_content "€10,000"
|
expect(page).to have_content "€10,000"
|
||||||
end
|
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
|
scenario "Confirm", :js do
|
||||||
budget.update(phase: 'balloting')
|
budget.update(phase: 'balloting')
|
||||||
user = create(:user, :level_two)
|
user = create(:user, :level_two)
|
||||||
|
|||||||
Reference in New Issue
Block a user