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
|
||||
create(:budget_investment,
|
||||
:winner,
|
||||
valuation_finished: true,
|
||||
:finished,
|
||||
title: "Investment winner",
|
||||
budget: budget)
|
||||
create(:budget_investment,
|
||||
@@ -483,8 +483,7 @@ describe "Admin budget investments" do
|
||||
|
||||
scenario "Filtering by valuation status" do
|
||||
valuating = create(:budget_investment, :with_administrator, budget: budget, title: "Ongoing valuation")
|
||||
valuated = create(:budget_investment, budget: budget, title: "Old idea",
|
||||
valuation_finished: true)
|
||||
valuated = create(:budget_investment, :finished, budget: budget, title: "Old idea")
|
||||
valuating.valuators.push(create(:valuator))
|
||||
valuated.valuators.push(create(:valuator))
|
||||
|
||||
@@ -701,10 +700,10 @@ describe "Admin budget investments" do
|
||||
end
|
||||
|
||||
scenario "Combination of select with text search", :js do
|
||||
create(:budget_investment, budget: budget, title: "Educate the children",
|
||||
feasibility: "feasible", valuation_finished: true)
|
||||
create(:budget_investment, budget: budget, title: "More schools",
|
||||
feasibility: "feasible", valuation_finished: true)
|
||||
create(:budget_investment, :finished, budget: budget, title: "Educate the children",
|
||||
feasibility: "feasible")
|
||||
create(:budget_investment, :finished, budget: budget, title: "More schools",
|
||||
feasibility: "feasible")
|
||||
create(:budget_investment, budget: budget, title: "More hospitals")
|
||||
|
||||
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")
|
||||
administrator = create(:administrator, user: user)
|
||||
|
||||
create(:budget_investment, budget: budget, title: "Educate the children",
|
||||
feasibility: "feasible", valuation_finished: true,
|
||||
create(:budget_investment, :finished, budget: budget, title: "Educate the children",
|
||||
feasibility: "feasible",
|
||||
administrator: administrator)
|
||||
create(:budget_investment, budget: budget, title: "More schools",
|
||||
feasibility: "feasible", valuation_finished: true,
|
||||
create(:budget_investment, :finished, budget: budget, title: "More schools",
|
||||
feasibility: "feasible",
|
||||
administrator: administrator)
|
||||
create(:budget_investment, budget: budget, title: "More hospitals",
|
||||
administrator: administrator)
|
||||
|
||||
@@ -519,7 +519,7 @@ describe "Budget Investments" do
|
||||
context("Filters") 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)
|
||||
investment3 = create(:budget_investment, heading: heading)
|
||||
investment4 = create(:budget_investment, :feasible, heading: heading)
|
||||
@@ -596,8 +596,7 @@ describe "Budget Investments" do
|
||||
end
|
||||
|
||||
scenario "unfeasible", :js 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)
|
||||
|
||||
visit budget_results_path(budget)
|
||||
@@ -1670,10 +1669,10 @@ describe "Budget Investments" do
|
||||
end
|
||||
|
||||
scenario "Show unselected budget investments" do
|
||||
investment1 = create(:budget_investment, :unselected, :feasible, heading: heading, valuation_finished: true)
|
||||
investment2 = create(:budget_investment, :selected, :feasible, heading: heading, valuation_finished: true)
|
||||
investment3 = create(:budget_investment, :selected, :feasible, heading: heading, valuation_finished: true)
|
||||
investment4 = create(:budget_investment, :selected, :feasible, heading: heading, valuation_finished: true)
|
||||
investment1 = create(:budget_investment, :unselected, :feasible, :finished, heading: heading)
|
||||
investment2 = create(:budget_investment, :selected, :feasible, :finished, heading: heading)
|
||||
investment3 = create(:budget_investment, :selected, :feasible, :finished, heading: heading)
|
||||
investment4 = create(:budget_investment, :selected, :feasible, :finished, heading: heading)
|
||||
|
||||
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
|
||||
valuating = create(:budget_investment, :visible_to_valuators, budget: budget,
|
||||
title: "Ongoing valuation")
|
||||
valuated = create(:budget_investment, :visible_to_valuators, budget: budget,
|
||||
title: "Old idea",
|
||||
valuation_finished: true)
|
||||
valuated = create(:budget_investment, :visible_to_valuators, :finished,
|
||||
budget: budget,
|
||||
title: "Old idea")
|
||||
valuating.valuators << valuator
|
||||
valuated.valuators << valuator
|
||||
|
||||
|
||||
@@ -262,9 +262,8 @@ describe Budget::Investment do
|
||||
describe "#should_show_unfeasibility_explanation?" do
|
||||
let(:budget) { create(:budget) }
|
||||
let(:investment) do
|
||||
create(:budget_investment, budget: budget,
|
||||
create(:budget_investment, :finished, budget: budget,
|
||||
unfeasibility_explanation: "because of reasons",
|
||||
valuation_finished: true,
|
||||
feasibility: "unfeasible")
|
||||
end
|
||||
|
||||
@@ -401,7 +400,7 @@ describe Budget::Investment do
|
||||
describe "scopes" do
|
||||
describe "valuation_open" 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)
|
||||
|
||||
valuation_open = Budget::Investment.valuation_open
|
||||
@@ -412,7 +411,7 @@ describe Budget::Investment do
|
||||
|
||||
describe "without_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)
|
||||
investment3 = create(:budget_investment)
|
||||
|
||||
@@ -425,7 +424,7 @@ describe Budget::Investment do
|
||||
describe "managed" do
|
||||
it "returns all open investments with assigned admin but without assigned valuators" do
|
||||
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)
|
||||
investment1.valuators << create(:valuator)
|
||||
|
||||
@@ -439,7 +438,7 @@ describe Budget::Investment do
|
||||
it "returns all investments with assigned valuator but valuation not finished" do
|
||||
investment1 = create(:budget_investment)
|
||||
investment2 = create(:budget_investment)
|
||||
investment3 = create(:budget_investment, valuation_finished: true)
|
||||
investment3 = create(:budget_investment, :finished)
|
||||
|
||||
investment2.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
|
||||
investment1 = 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)
|
||||
investment3.valuator_groups << create(:valuator_group)
|
||||
@@ -467,7 +466,7 @@ describe Budget::Investment do
|
||||
it "returns all investments with valuation finished" do
|
||||
investment1 = create(:budget_investment)
|
||||
investment2 = create(:budget_investment)
|
||||
investment3 = create(:budget_investment, valuation_finished: true)
|
||||
investment3 = create(:budget_investment, :finished)
|
||||
|
||||
investment2.valuators << create(:valuator)
|
||||
investment3.valuators << create(:valuator)
|
||||
@@ -1262,13 +1261,8 @@ describe Budget::Investment do
|
||||
describe "with winners filter" do
|
||||
let(:params) { { advanced_filters: ["winners"], budget_id: budget.id } }
|
||||
it "returns only investment winners" do
|
||||
investment1 = create(:budget_investment,
|
||||
:winner,
|
||||
valuation_finished: true,
|
||||
budget: budget)
|
||||
create(:budget_investment,
|
||||
:with_administrator,
|
||||
budget: budget)
|
||||
investment1 = create(:budget_investment, :winner, :finished, budget: budget)
|
||||
create(:budget_investment, :with_administrator, budget: budget)
|
||||
create(:budget_investment, budget: budget)
|
||||
|
||||
expect(Budget::Investment.scoped_filter(params, "all")).to eq([investment1])
|
||||
|
||||
Reference in New Issue
Block a user