Add feasible investments filter again

We removed it in commit c322b2c4a because it was hard to know the
difference between "Feasible" and "Not unfeasible". We're renaming the
"Not unfeasible" filter instead.

We're also moving the "selected" filter so it appears before the
"unselected" filter, just like the "feasible" filter appears before the
"unfeasible" filter.
This commit is contained in:
Javi Martín
2021-09-16 00:49:32 +02:00
parent 1bfcfca2e2
commit 56ac154d1f
5 changed files with 22 additions and 11 deletions

View File

@@ -199,9 +199,10 @@ class Budget < ApplicationRecord
def investments_filters def investments_filters
[ [
"not_unfeasible", "not_unfeasible",
"feasible",
"unfeasible", "unfeasible",
("unselected" if publishing_prices_or_later?),
("selected" if publishing_prices_or_later?), ("selected" if publishing_prices_or_later?),
("unselected" if publishing_prices_or_later?),
("winners" if finished?) ("winners" if finished?)
].compact ].compact
end end

View File

@@ -121,7 +121,8 @@ en:
not_logged_in: "To create a new budget investment you must %{sign_in} or %{sign_up}." not_logged_in: "To create a new budget investment you must %{sign_in} or %{sign_up}."
filter: "Filtering projects by" filter: "Filtering projects by"
filters: filters:
not_unfeasible: "Not unfeasible" feasible: "Feasible"
not_unfeasible: "Feasible or with undecided feasibility"
selected: "Selected" selected: "Selected"
unfeasible: "Unfeasible" unfeasible: "Unfeasible"
unselected: "Unselected" unselected: "Unselected"

View File

@@ -121,7 +121,8 @@ es:
not_logged_in: "Para crear un nuevo proyecto de gasto debes %{sign_in} o %{sign_up}." not_logged_in: "Para crear un nuevo proyecto de gasto debes %{sign_in} o %{sign_up}."
filter: "Filtrando proyectos" filter: "Filtrando proyectos"
filters: filters:
not_unfeasible: "No inviables" feasible: "Viables"
not_unfeasible: "Viables o con viabilidad por decidir"
selected: "Seleccionados" selected: "Seleccionados"
unfeasible: "Inviables" unfeasible: "Inviables"
unselected: "No seleccionados" unselected: "No seleccionados"

View File

@@ -290,7 +290,7 @@ describe Budget do
%w[informing accepting reviewing selecting valuating].each do |phase| %w[informing accepting reviewing selecting valuating].each do |phase|
budget.phase = phase budget.phase = phase
expect(budget.investments_filters).to eq(%w[not_unfeasible unfeasible]) expect(budget.investments_filters).to eq(%w[not_unfeasible feasible unfeasible])
end end
end end
@@ -298,14 +298,14 @@ describe Budget do
%w[publishing_prices balloting reviewing_ballots].each do |phase| %w[publishing_prices balloting reviewing_ballots].each do |phase|
budget.phase = phase budget.phase = phase
expect(budget.investments_filters).to eq(%w[not_unfeasible unfeasible unselected selected]) expect(budget.investments_filters).to eq(%w[not_unfeasible feasible unfeasible selected unselected])
end end
end end
it "returns all filters after the budget has finished" do it "returns all filters after the budget has finished" do
budget.phase = "finished" budget.phase = "finished"
expect(budget.investments_filters).to eq(%w[not_unfeasible unfeasible unselected selected winners]) expect(budget.investments_filters).to eq(%w[not_unfeasible feasible unfeasible selected unselected winners])
end end
end end

View File

@@ -131,6 +131,7 @@ describe "Budget Investments" do
scenario "Index filter by status" do scenario "Index filter by status" do
budget.update!(phase: "finished") budget.update!(phase: "finished")
create(:budget_investment, heading: heading, title: "Unclassified investment")
create(:budget_investment, :feasible, heading: heading, title: "Feasible investment") create(:budget_investment, :feasible, heading: heading, title: "Feasible investment")
create(:budget_investment, :unfeasible, heading: heading, title: "Unfeasible investment") create(:budget_investment, :unfeasible, heading: heading, title: "Unfeasible investment")
create(:budget_investment, :unselected, heading: heading, title: "Unselected investment") create(:budget_investment, :unselected, heading: heading, title: "Unselected investment")
@@ -141,34 +142,41 @@ describe "Budget Investments" do
expect(page).to have_content "FILTERING PROJECTS BY" expect(page).to have_content "FILTERING PROJECTS BY"
click_link "Unfeasible" click_link "Feasible"
expect(page).to have_css ".budget-investment", count: 1 expect(page).to have_css ".budget-investment", count: 1
expect(page).to have_content "Feasible investment"
click_link "Unfeasible"
expect(page).to have_content "Unfeasible investment" expect(page).to have_content "Unfeasible investment"
expect(page).to have_css ".budget-investment", count: 1
click_link "Unselected" click_link "Unselected"
expect(page).to have_css ".budget-investment", count: 2 expect(page).to have_css ".budget-investment", count: 3
expect(page).to have_content "Unselected investment" expect(page).to have_content "Unselected investment"
expect(page).to have_content "Unclassified investment"
expect(page).to have_content "Feasible investment" expect(page).to have_content "Feasible investment"
click_link "Selected" click_link "Selected"
expect(page).to have_css ".budget-investment", count: 2
expect(page).to have_content "Selected investment" expect(page).to have_content "Selected investment"
expect(page).to have_content "Winner investment" expect(page).to have_content "Winner investment"
expect(page).to have_css ".budget-investment", count: 2
click_link "Winners" click_link "Winners"
expect(page).to have_css ".budget-investment", count: 1 expect(page).to have_css ".budget-investment", count: 1
expect(page).to have_content "Winner investment" expect(page).to have_content "Winner investment"
click_link "Not unfeasible" click_link "Feasible or with undecided feasibility"
expect(page).to have_css ".budget-investment", count: 4 expect(page).to have_css ".budget-investment", count: 5
expect(page).to have_content "Selected investment" expect(page).to have_content "Selected investment"
expect(page).to have_content "Unselected investment" expect(page).to have_content "Unselected investment"
expect(page).to have_content "Feasible investment" expect(page).to have_content "Feasible investment"
expect(page).to have_content "Unclassified investment"
expect(page).to have_content "Winner investment" expect(page).to have_content "Winner investment"
end end