Adds voting in selecting phase
This commit is contained in:
@@ -43,18 +43,23 @@
|
||||
</div>
|
||||
|
||||
<% unless investment.unfeasible? %>
|
||||
<% if feature?("investment_features.phase2") %>
|
||||
|
||||
<% if @budget.selecting? || @budget.on_hold? %>
|
||||
|
||||
<div id="<%= dom_id(investment) %>_votes"
|
||||
class="small-12 medium-3 column text-center">
|
||||
<%= render 'votes',
|
||||
{ investment: investment, vote_url: vote_investment_path(investment, value: 'yes') } %>
|
||||
{ investment: investment,
|
||||
vote_url: vote_budget_investment_path(@budget, investment, value: 'yes') } %>
|
||||
</div>
|
||||
|
||||
<% elsif feature?("investment_features.phase3") %>
|
||||
<div id="<%= dom_id(investment) %>_ballot"
|
||||
class="small-12 medium-3 column text-center">
|
||||
<%= render 'ballot', investment: investment %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="supported">
|
||||
<%= t("budget.investments.investment.already_supported") %>
|
||||
</div>
|
||||
<% elsif voting_allowed %>
|
||||
<% elsif @budget.selecting? %>
|
||||
|
||||
<%= link_to vote_url,
|
||||
class: "button button-support small expanded",
|
||||
|
||||
@@ -45,15 +45,19 @@
|
||||
</div>
|
||||
|
||||
<% if (@budget.selecting? && !@investment.unfeasible?) ||
|
||||
(@budget.balloting? && @investment.feasible?) %>
|
||||
(@budget.balloting? && @investment.feasible? ||
|
||||
(@budget.on_hold?)) %>
|
||||
<aside class="small-12 medium-3 column">
|
||||
<div class="sidebar-divider"></div>
|
||||
<h3><%= t("votes.supports") %></h3>
|
||||
<div class="text-center">
|
||||
<% if @budget.selecting? %>
|
||||
|
||||
<% if @budget.selecting? || @budget.on_hold? %>
|
||||
<div id="<%= dom_id(@investment) %>_votes">
|
||||
<%= render 'votes',
|
||||
{ investment: @investment, vote_url: vote_budget_investment_path(budget_id: @budget.id, id: @investment.id) } %>
|
||||
{ investment: @investment,
|
||||
vote_url: vote_budget_investment_path(@budget, @investment, value: 'yes') }
|
||||
%>
|
||||
</div>
|
||||
<% else %>
|
||||
<div id="<%= dom_id(@investment) %>_ballot">
|
||||
|
||||
1
app/views/budgets/investments/vote.js.erb
Normal file
1
app/views/budgets/investments/vote.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$("#<%= dom_id(@investment) %>_votes").html('<%= j render("budgets/investments/votes", investment: @investment, vote_url: vote_budget_investment_path(@budget, @investment, value: "yes")) %>');
|
||||
@@ -434,25 +434,127 @@ feature 'Votes' do
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Disable voting on spending proposals', :js do
|
||||
login_as(@manuela)
|
||||
Setting["feature.spending_proposal_features.voting_allowed"] = nil
|
||||
spending_proposal = create(:spending_proposal)
|
||||
scenario 'Disable voting on spending proposals', :js do
|
||||
login_as(@manuela)
|
||||
Setting["feature.spending_proposal_features.voting_allowed"] = nil
|
||||
spending_proposal = create(:spending_proposal)
|
||||
|
||||
visit spending_proposals_path
|
||||
visit spending_proposals_path
|
||||
|
||||
within("#spending_proposal_#{spending_proposal.id}") do
|
||||
find("div.supports").hover
|
||||
expect_message_voting_not_allowed
|
||||
end
|
||||
within("#spending_proposal_#{spending_proposal.id}") do
|
||||
find("div.supports").hover
|
||||
expect_message_voting_not_allowed
|
||||
end
|
||||
|
||||
visit spending_proposal_path(spending_proposal)
|
||||
visit spending_proposal_path(spending_proposal)
|
||||
|
||||
within("#spending_proposal_#{spending_proposal.id}") do
|
||||
find("div.supports").hover
|
||||
expect_message_voting_not_allowed
|
||||
within("#spending_proposal_#{spending_proposal.id}") do
|
||||
find("div.supports").hover
|
||||
expect_message_voting_not_allowed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Investments' do
|
||||
|
||||
let(:budget) { create(:budget, phase: "selecting") }
|
||||
let(:group) { create(:budget_group, budget: budget) }
|
||||
let(:heading) { create(:budget_heading, group: group) }
|
||||
|
||||
background { login_as(@manuela) }
|
||||
|
||||
feature 'Index' do
|
||||
|
||||
scenario "Index shows user votes on proposals" do
|
||||
investment1 = create(:budget_investment, heading: heading)
|
||||
investment2 = create(:budget_investment, heading: heading)
|
||||
investment3 = create(:budget_investment, heading: heading)
|
||||
create(:vote, voter: @manuela, votable: investment1, vote_flag: true)
|
||||
|
||||
visit budget_investments_path(budget_id: budget.id)
|
||||
|
||||
within("#budget-investments") do
|
||||
within("#budget_investment_#{investment1.id}_votes") do
|
||||
expect(page).to have_content "You have already supported this. Share it!"
|
||||
end
|
||||
|
||||
within("#budget_investment_#{investment2.id}_votes") do
|
||||
expect(page).to_not have_content "You have already supported this. Share it!"
|
||||
end
|
||||
|
||||
within("#budget_investment_#{investment3.id}_votes") do
|
||||
expect(page).to_not have_content "You have already supported this. Share it!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create from spending proposal index', :js do
|
||||
investment = create(:budget_investment, heading: heading, budget: budget)
|
||||
|
||||
visit budget_investments_path(budget_id: budget.id)
|
||||
|
||||
within('.supports') do
|
||||
find('.in-favor a').click
|
||||
|
||||
expect(page).to have_content "1 support"
|
||||
expect(page).to have_content "You have already supported this. Share it!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Single spending proposal' do
|
||||
background do
|
||||
@investment = create(:budget_investment, budget: budget)
|
||||
end
|
||||
|
||||
scenario 'Show no votes' do
|
||||
visit budget_investment_path(budget, @investment)
|
||||
expect(page).to have_content "No supports"
|
||||
end
|
||||
|
||||
scenario 'Trying to vote multiple times', :js do
|
||||
visit budget_investment_path(budget, @investment)
|
||||
|
||||
within('.supports') do
|
||||
find('.in-favor a').click
|
||||
expect(page).to have_content "1 support"
|
||||
|
||||
expect(page).to_not have_selector ".in-favor a"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create from proposal show', :js do
|
||||
visit budget_investment_path(budget, @investment)
|
||||
|
||||
within('.supports') do
|
||||
find('.in-favor a').click
|
||||
|
||||
expect(page).to have_content "1 support"
|
||||
expect(page).to have_content "You have already supported this. Share it!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Disable voting on spending proposals', :js do
|
||||
login_as(@manuela)
|
||||
budget.update(phase: "on_hold")
|
||||
investment = create(:budget_investment, budget: budget)
|
||||
|
||||
visit budget_investments_path(budget)
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find("div.supports").hover
|
||||
expect_message_selecting_not_allowed
|
||||
end
|
||||
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find("div.supports").hover
|
||||
expect_message_selecting_not_allowed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -180,6 +180,11 @@ module CommonActions
|
||||
expect(page).to_not have_selector('.in-favor a')
|
||||
end
|
||||
|
||||
def expect_message_selecting_not_allowed
|
||||
expect(page).to have_content 'No Selecting Allowed'
|
||||
expect(page).to_not have_selector('.in-favor a')
|
||||
end
|
||||
|
||||
def create_featured_proposals
|
||||
[create(:proposal, :with_confidence_score, cached_votes_up: 100),
|
||||
create(:proposal, :with_confidence_score, cached_votes_up: 90),
|
||||
|
||||
Reference in New Issue
Block a user