Don't show investment filters before valuation

Before the "valuating" phase, all investments have undecided feasibility
and none have been selected, so the filters would return no results
(except the "not_unfeasible" one, which would return everything).
This commit is contained in:
Javi Martín
2021-09-16 00:52:06 +02:00
parent 56ac154d1f
commit 28a7aea1c0
4 changed files with 52 additions and 10 deletions

View File

@@ -0,0 +1,33 @@
require "rails_helper"
describe Budgets::Investments::FiltersComponent do
let(:budget) { create(:budget) }
around do |example|
with_request_url(Rails.application.routes.url_helpers.budget_investments_path(budget)) do
example.run
end
end
it "is not displayed before valuation" do
%w[informing accepting reviewing selecting].each do |phase|
budget.update!(phase: phase)
allow(controller).to receive(:valid_filters).and_return(budget.investments_filters)
render_inline Budgets::Investments::FiltersComponent.new
expect(page.native.inner_html).to be_empty
end
end
it "is displayed during and after valuation" do
Budget::Phase::kind_or_later("valuating").each do |phase|
budget.update!(phase: phase)
allow(controller).to receive(:valid_filters).and_return(budget.investments_filters)
render_inline Budgets::Investments::FiltersComponent.new
expect(page).to have_content "Filtering projects by"
end
end
end