From 470fe4158541c79b15790a03206be667deea8dcb Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 13 Jan 2017 11:13:01 +0100 Subject: [PATCH 1/2] only displays vote button in selecting phase --- app/models/budget/investment.rb | 2 +- spec/models/budget/investment_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 5389825e5..dd98e472e 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -199,7 +199,7 @@ class Budget end def should_show_votes? - budget.selecting? || budget.on_hold? + budget.selecting? end def should_show_ballots? diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 0c6615a99..35839e560 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -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) From dbf8b865183eeecd4a8411c9f3365a8df67a7480 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 13 Jan 2017 11:37:06 +0100 Subject: [PATCH 2/2] fixes specs --- spec/features/budgets/votes_spec.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/features/budgets/votes_spec.rb b/spec/features/budgets/votes_spec.rb index c31545428..e12d359cc 100644 --- a/spec/features/budgets/votes_spec.rb +++ b/spec/features/budgets/votes_spec.rb @@ -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