Merge pull request #1539 from consul/budgets-unselected

Do not display voting button for unselected investments
This commit is contained in:
Raimond Garcia
2017-05-14 21:33:57 +02:00
committed by GitHub
3 changed files with 29 additions and 4 deletions

View File

@@ -216,7 +216,7 @@ class Budget
end end
def should_show_ballots? def should_show_ballots?
budget.balloting? budget.balloting? && selected?
end end
def should_show_price? def should_show_price?

View File

@@ -652,6 +652,24 @@ feature 'Budget Investments' do
expect(page).to have_current_path(expected_path) expect(page).to have_current_path(expected_path)
end end
scenario "Do not display vote button for unselected investments in index" do
investment = create(:budget_investment, :unselected, heading: heading)
visit budget_investments_path(budget_id: budget.id, heading_id: heading.id, filter: "unselected")
expect(page).to have_content investment.title
expect(page).to_not have_link("Vote")
end
scenario "Do not display vote button for unselected investments in show" do
investment = create(:budget_investment, :unselected, heading: heading)
visit budget_investment_path(budget, investment)
expect(page).to have_content investment.title
expect(page).to_not have_link("Vote")
end
scenario "Reclassification" do scenario "Reclassification" do
user = create(:user, :level_two) user = create(:user, :level_two)
investment = create(:budget_investment, :selected, heading: heading) investment = create(:budget_investment, :selected, heading: heading)

View File

@@ -163,17 +163,24 @@ describe Budget::Investment do
end end
describe "#should_show_ballots?" do describe "#should_show_ballots?" do
it "returns true in balloting phase" do it "returns true in balloting phase for selected investments" do
budget = create(:budget, phase: "balloting") budget = create(:budget, phase: "balloting")
investment = create(:budget_investment, budget: budget) investment = create(:budget_investment, :selected, budget: budget)
expect(investment.should_show_ballots?).to eq(true) expect(investment.should_show_ballots?).to eq(true)
end end
it "returns false for unselected investments" do
budget = create(:budget, phase: "balloting")
investment = create(:budget_investment, :unselected, budget: budget)
expect(investment.should_show_ballots?).to eq(false)
end
it "returns false in any other phase" do it "returns false in any other phase" do
Budget::PHASES.reject {|phase| phase == "balloting"}.each do |phase| Budget::PHASES.reject {|phase| phase == "balloting"}.each do |phase|
budget = create(:budget, phase: phase) budget = create(:budget, phase: phase)
investment = create(:budget_investment, budget: budget) investment = create(:budget_investment, :selected, budget: budget)
expect(investment.should_show_ballots?).to eq(false) expect(investment.should_show_ballots?).to eq(false)
end end