Merge pull request #1347 from consul/budgets-vote-button

only displays vote button in selecting phase
This commit is contained in:
Juanjo Bazán
2017-01-13 11:58:28 +01:00
committed by GitHub
3 changed files with 21 additions and 5 deletions

View File

@@ -199,7 +199,7 @@ class Budget
end
def should_show_votes?
budget.selecting? || budget.on_hold?
budget.selecting?
end
def should_show_ballots?

View File

@@ -94,15 +94,13 @@ feature 'Votes' do
visit budget_investments_path(budget, heading_id: heading.id)
within("#budget_investment_#{investment.id}") do
find("div.js-participation").hover
expect(page).to have_content 'No Selecting Allowed'
expect(page).to_not have_css("budget_investment_#{investment.id}_votes")
end
visit budget_investment_path(budget, investment)
within("#budget_investment_#{investment.id}") do
find("div.js-participation").hover
expect(page).to have_content 'No Selecting Allowed'
expect(page).to_not have_css("budget_investment_#{investment.id}_votes")
end
end
end

View File

@@ -65,6 +65,24 @@ describe Budget::Investment do
end
end
describe "#should_show_votes?" do
it "returns true in selecting phase" do
budget = create(:budget, phase: "selecting")
investment = create(:budget_investment, budget: budget)
expect(investment.should_show_votes?).to eq(true)
end
it "returns false in any other phase" do
Budget::PHASES.reject {|phase| phase == "selecting"}.each do |phase|
budget = create(:budget, phase: phase)
investment = create(:budget_investment, budget: budget)
expect(investment.should_show_votes?).to eq(false)
end
end
end
describe "by_admin" do
it "should return investments assigned to specific administrator" do
investment1 = create(:budget_investment, administrator_id: 33)