Use finished trait to simplify code
It's more concise than writing `valuation_finished: true`.
This commit is contained in:
@@ -407,7 +407,7 @@ describe "Admin budget investments" do
|
|||||||
scenario "Filtering by winners", :js do
|
scenario "Filtering by winners", :js do
|
||||||
create(:budget_investment,
|
create(:budget_investment,
|
||||||
:winner,
|
:winner,
|
||||||
valuation_finished: true,
|
:finished,
|
||||||
title: "Investment winner",
|
title: "Investment winner",
|
||||||
budget: budget)
|
budget: budget)
|
||||||
create(:budget_investment,
|
create(:budget_investment,
|
||||||
@@ -483,8 +483,7 @@ describe "Admin budget investments" do
|
|||||||
|
|
||||||
scenario "Filtering by valuation status" do
|
scenario "Filtering by valuation status" do
|
||||||
valuating = create(:budget_investment, :with_administrator, budget: budget, title: "Ongoing valuation")
|
valuating = create(:budget_investment, :with_administrator, budget: budget, title: "Ongoing valuation")
|
||||||
valuated = create(:budget_investment, budget: budget, title: "Old idea",
|
valuated = create(:budget_investment, :finished, budget: budget, title: "Old idea")
|
||||||
valuation_finished: true)
|
|
||||||
valuating.valuators.push(create(:valuator))
|
valuating.valuators.push(create(:valuator))
|
||||||
valuated.valuators.push(create(:valuator))
|
valuated.valuators.push(create(:valuator))
|
||||||
|
|
||||||
@@ -701,10 +700,10 @@ describe "Admin budget investments" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Combination of select with text search", :js do
|
scenario "Combination of select with text search", :js do
|
||||||
create(:budget_investment, budget: budget, title: "Educate the children",
|
create(:budget_investment, :finished, budget: budget, title: "Educate the children",
|
||||||
feasibility: "feasible", valuation_finished: true)
|
feasibility: "feasible")
|
||||||
create(:budget_investment, budget: budget, title: "More schools",
|
create(:budget_investment, :finished, budget: budget, title: "More schools",
|
||||||
feasibility: "feasible", valuation_finished: true)
|
feasibility: "feasible")
|
||||||
create(:budget_investment, budget: budget, title: "More hospitals")
|
create(:budget_investment, budget: budget, title: "More hospitals")
|
||||||
|
|
||||||
visit admin_budget_budget_investments_path(budget_id: budget.id)
|
visit admin_budget_budget_investments_path(budget_id: budget.id)
|
||||||
@@ -741,11 +740,11 @@ describe "Admin budget investments" do
|
|||||||
user = create(:user, username: "Admin 1")
|
user = create(:user, username: "Admin 1")
|
||||||
administrator = create(:administrator, user: user)
|
administrator = create(:administrator, user: user)
|
||||||
|
|
||||||
create(:budget_investment, budget: budget, title: "Educate the children",
|
create(:budget_investment, :finished, budget: budget, title: "Educate the children",
|
||||||
feasibility: "feasible", valuation_finished: true,
|
feasibility: "feasible",
|
||||||
administrator: administrator)
|
administrator: administrator)
|
||||||
create(:budget_investment, budget: budget, title: "More schools",
|
create(:budget_investment, :finished, budget: budget, title: "More schools",
|
||||||
feasibility: "feasible", valuation_finished: true,
|
feasibility: "feasible",
|
||||||
administrator: administrator)
|
administrator: administrator)
|
||||||
create(:budget_investment, budget: budget, title: "More hospitals",
|
create(:budget_investment, budget: budget, title: "More hospitals",
|
||||||
administrator: administrator)
|
administrator: administrator)
|
||||||
|
|||||||
@@ -519,7 +519,7 @@ describe "Budget Investments" do
|
|||||||
context("Filters") do
|
context("Filters") do
|
||||||
|
|
||||||
scenario "by unfeasibility" do
|
scenario "by unfeasibility" do
|
||||||
investment1 = create(:budget_investment, :unfeasible, heading: heading, valuation_finished: true)
|
investment1 = create(:budget_investment, :unfeasible, :finished, heading: heading)
|
||||||
investment2 = create(:budget_investment, :feasible, heading: heading)
|
investment2 = create(:budget_investment, :feasible, heading: heading)
|
||||||
investment3 = create(:budget_investment, heading: heading)
|
investment3 = create(:budget_investment, heading: heading)
|
||||||
investment4 = create(:budget_investment, :feasible, heading: heading)
|
investment4 = create(:budget_investment, :feasible, heading: heading)
|
||||||
@@ -596,8 +596,7 @@ describe "Budget Investments" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "unfeasible", :js do
|
scenario "unfeasible", :js do
|
||||||
investment1 = create(:budget_investment, :unfeasible, heading: heading,
|
investment1 = create(:budget_investment, :unfeasible, :finished, heading: heading)
|
||||||
valuation_finished: true)
|
|
||||||
investment2 = create(:budget_investment, :feasible, heading: heading)
|
investment2 = create(:budget_investment, :feasible, heading: heading)
|
||||||
|
|
||||||
visit budget_results_path(budget)
|
visit budget_results_path(budget)
|
||||||
@@ -1670,10 +1669,10 @@ describe "Budget Investments" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Show unselected budget investments" do
|
scenario "Show unselected budget investments" do
|
||||||
investment1 = create(:budget_investment, :unselected, :feasible, heading: heading, valuation_finished: true)
|
investment1 = create(:budget_investment, :unselected, :feasible, :finished, heading: heading)
|
||||||
investment2 = create(:budget_investment, :selected, :feasible, heading: heading, valuation_finished: true)
|
investment2 = create(:budget_investment, :selected, :feasible, :finished, heading: heading)
|
||||||
investment3 = create(:budget_investment, :selected, :feasible, heading: heading, valuation_finished: true)
|
investment3 = create(:budget_investment, :selected, :feasible, :finished, heading: heading)
|
||||||
investment4 = create(:budget_investment, :selected, :feasible, heading: heading, valuation_finished: true)
|
investment4 = create(:budget_investment, :selected, :feasible, :finished, heading: heading)
|
||||||
|
|
||||||
visit budget_investments_path(budget, heading_id: heading.id, filter: "unselected")
|
visit budget_investments_path(budget, heading_id: heading.id, filter: "unselected")
|
||||||
|
|
||||||
|
|||||||
@@ -210,9 +210,9 @@ describe "Valuation budget investments" do
|
|||||||
scenario "Index filtering by valuation status" do
|
scenario "Index filtering by valuation status" do
|
||||||
valuating = create(:budget_investment, :visible_to_valuators, budget: budget,
|
valuating = create(:budget_investment, :visible_to_valuators, budget: budget,
|
||||||
title: "Ongoing valuation")
|
title: "Ongoing valuation")
|
||||||
valuated = create(:budget_investment, :visible_to_valuators, budget: budget,
|
valuated = create(:budget_investment, :visible_to_valuators, :finished,
|
||||||
title: "Old idea",
|
budget: budget,
|
||||||
valuation_finished: true)
|
title: "Old idea")
|
||||||
valuating.valuators << valuator
|
valuating.valuators << valuator
|
||||||
valuated.valuators << valuator
|
valuated.valuators << valuator
|
||||||
|
|
||||||
|
|||||||
@@ -262,9 +262,8 @@ describe Budget::Investment do
|
|||||||
describe "#should_show_unfeasibility_explanation?" do
|
describe "#should_show_unfeasibility_explanation?" do
|
||||||
let(:budget) { create(:budget) }
|
let(:budget) { create(:budget) }
|
||||||
let(:investment) do
|
let(:investment) do
|
||||||
create(:budget_investment, budget: budget,
|
create(:budget_investment, :finished, budget: budget,
|
||||||
unfeasibility_explanation: "because of reasons",
|
unfeasibility_explanation: "because of reasons",
|
||||||
valuation_finished: true,
|
|
||||||
feasibility: "unfeasible")
|
feasibility: "unfeasible")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -401,7 +400,7 @@ describe Budget::Investment do
|
|||||||
describe "scopes" do
|
describe "scopes" do
|
||||||
describe "valuation_open" do
|
describe "valuation_open" do
|
||||||
it "returns all investments with false valuation_finished" do
|
it "returns all investments with false valuation_finished" do
|
||||||
investment1 = create(:budget_investment, valuation_finished: true)
|
investment1 = create(:budget_investment, :finished)
|
||||||
investment2 = create(:budget_investment)
|
investment2 = create(:budget_investment)
|
||||||
|
|
||||||
valuation_open = Budget::Investment.valuation_open
|
valuation_open = Budget::Investment.valuation_open
|
||||||
@@ -412,7 +411,7 @@ describe Budget::Investment do
|
|||||||
|
|
||||||
describe "without_admin" do
|
describe "without_admin" do
|
||||||
it "returns all open investments without assigned admin" do
|
it "returns all open investments without assigned admin" do
|
||||||
investment1 = create(:budget_investment, valuation_finished: true)
|
investment1 = create(:budget_investment, :finished)
|
||||||
investment2 = create(:budget_investment, :with_administrator)
|
investment2 = create(:budget_investment, :with_administrator)
|
||||||
investment3 = create(:budget_investment)
|
investment3 = create(:budget_investment)
|
||||||
|
|
||||||
@@ -425,7 +424,7 @@ describe Budget::Investment do
|
|||||||
describe "managed" do
|
describe "managed" do
|
||||||
it "returns all open investments with assigned admin but without assigned valuators" do
|
it "returns all open investments with assigned admin but without assigned valuators" do
|
||||||
investment1 = create(:budget_investment, :with_administrator)
|
investment1 = create(:budget_investment, :with_administrator)
|
||||||
investment2 = create(:budget_investment, :with_administrator, valuation_finished: true)
|
investment2 = create(:budget_investment, :with_administrator, :finished)
|
||||||
investment3 = create(:budget_investment, :with_administrator)
|
investment3 = create(:budget_investment, :with_administrator)
|
||||||
investment1.valuators << create(:valuator)
|
investment1.valuators << create(:valuator)
|
||||||
|
|
||||||
@@ -439,7 +438,7 @@ describe Budget::Investment do
|
|||||||
it "returns all investments with assigned valuator but valuation not finished" do
|
it "returns all investments with assigned valuator but valuation not finished" do
|
||||||
investment1 = create(:budget_investment)
|
investment1 = create(:budget_investment)
|
||||||
investment2 = create(:budget_investment)
|
investment2 = create(:budget_investment)
|
||||||
investment3 = create(:budget_investment, valuation_finished: true)
|
investment3 = create(:budget_investment, :finished)
|
||||||
|
|
||||||
investment2.valuators << create(:valuator)
|
investment2.valuators << create(:valuator)
|
||||||
investment3.valuators << create(:valuator)
|
investment3.valuators << create(:valuator)
|
||||||
@@ -452,7 +451,7 @@ describe Budget::Investment do
|
|||||||
it "returns all investments with assigned valuator groups but valuation not finished" do
|
it "returns all investments with assigned valuator groups but valuation not finished" do
|
||||||
investment1 = create(:budget_investment)
|
investment1 = create(:budget_investment)
|
||||||
investment2 = create(:budget_investment)
|
investment2 = create(:budget_investment)
|
||||||
investment3 = create(:budget_investment, valuation_finished: true)
|
investment3 = create(:budget_investment, :finished)
|
||||||
|
|
||||||
investment2.valuator_groups << create(:valuator_group)
|
investment2.valuator_groups << create(:valuator_group)
|
||||||
investment3.valuator_groups << create(:valuator_group)
|
investment3.valuator_groups << create(:valuator_group)
|
||||||
@@ -467,7 +466,7 @@ describe Budget::Investment do
|
|||||||
it "returns all investments with valuation finished" do
|
it "returns all investments with valuation finished" do
|
||||||
investment1 = create(:budget_investment)
|
investment1 = create(:budget_investment)
|
||||||
investment2 = create(:budget_investment)
|
investment2 = create(:budget_investment)
|
||||||
investment3 = create(:budget_investment, valuation_finished: true)
|
investment3 = create(:budget_investment, :finished)
|
||||||
|
|
||||||
investment2.valuators << create(:valuator)
|
investment2.valuators << create(:valuator)
|
||||||
investment3.valuators << create(:valuator)
|
investment3.valuators << create(:valuator)
|
||||||
@@ -1262,13 +1261,8 @@ describe Budget::Investment do
|
|||||||
describe "with winners filter" do
|
describe "with winners filter" do
|
||||||
let(:params) { { advanced_filters: ["winners"], budget_id: budget.id } }
|
let(:params) { { advanced_filters: ["winners"], budget_id: budget.id } }
|
||||||
it "returns only investment winners" do
|
it "returns only investment winners" do
|
||||||
investment1 = create(:budget_investment,
|
investment1 = create(:budget_investment, :winner, :finished, budget: budget)
|
||||||
:winner,
|
create(:budget_investment, :with_administrator, budget: budget)
|
||||||
valuation_finished: true,
|
|
||||||
budget: budget)
|
|
||||||
create(:budget_investment,
|
|
||||||
:with_administrator,
|
|
||||||
budget: budget)
|
|
||||||
create(:budget_investment, budget: budget)
|
create(:budget_investment, budget: budget)
|
||||||
|
|
||||||
expect(Budget::Investment.scoped_filter(params, "all")).to eq([investment1])
|
expect(Budget::Investment.scoped_filter(params, "all")).to eq([investment1])
|
||||||
|
|||||||
Reference in New Issue
Block a user