Fix display of unfeasibility explanation

We were missing a check to make sure valuation had finished before
displaying the unfeasibility explanation
This commit is contained in:
rgarcia
2018-03-04 22:29:40 +01:00
parent 0e61d49800
commit 71bb5b3dcf
4 changed files with 69 additions and 2 deletions

View File

@@ -263,7 +263,52 @@ describe Budget::Investment do
end
end
describe "by_admin" do
describe "#should_show_unfeasibility_explanation?" do
let(:budget) { create(:budget) }
let(:investment) do
create(:budget_investment, budget: budget,
unfeasibility_explanation: "because of reasons",
valuation_finished: true,
feasibility: "unfeasible")
end
it "returns true for unfeasible investments with unfeasibility explanation and valuation finished" do
Budget::Phase::PUBLISHED_PRICES_PHASES.each do |phase|
budget.update(phase: phase)
expect(investment.should_show_unfeasibility_explanation?).to eq(true)
end
end
it "returns false in valuation has not finished" do
investment.update(valuation_finished: false)
Budget::Phase::PUBLISHED_PRICES_PHASES.each do |phase|
budget.update(phase: phase)
expect(investment.should_show_unfeasibility_explanation?).to eq(false)
end
end
it "returns false if not unfeasible" do
investment.update(feasibility: "undecided")
Budget::Phase::PUBLISHED_PRICES_PHASES.each do |phase|
budget.update(phase: phase)
expect(investment.should_show_unfeasibility_explanation?).to eq(false)
end
end
it "returns false if unfeasibility explanation blank" do
investment.update(unfeasibility_explanation: "")
Budget::Phase::PUBLISHED_PRICES_PHASES.each do |phase|
budget.update(phase: phase)
expect(investment.should_show_unfeasibility_explanation?).to eq(false)
end
end
end
describe "#by_admin" do
it "returns investments assigned to specific administrator" do
investment1 = create(:budget_investment, administrator_id: 33)
create(:budget_investment)