Fix crash with budgets with disabled current phase
There's an edge case where the current phase of the budget was disabled. In this case, the application was crashing. I'm not sure what we should do regarding this case. Is it OK to allow disabling the current phase? Is it OK to allow selecting a disabled phase as the current phase? Since I'm not sure about it, for now I'm leaving it the same way it was. Co-authored-by: Julian Herrero <microweb10@gmail.com>
This commit is contained in:
18
spec/components/admin/budgets/index_component_spec.rb
Normal file
18
spec/components/admin/budgets/index_component_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Budgets::IndexComponent, type: :component do
|
||||
before do
|
||||
allow(ViewComponent::Base).to receive(:test_controller).and_return("Admin::BudgetsController")
|
||||
allow_any_instance_of(Admin::BudgetsController).to receive(:valid_filters).and_return(["all"])
|
||||
allow_any_instance_of(Admin::BudgetsController).to receive(:current_filter).and_return("all")
|
||||
end
|
||||
|
||||
it "displays current phase zero for budgets with no current phase" do
|
||||
budget = create(:budget, :accepting, name: "Not enabled phase")
|
||||
budget.phases.accepting.update!(enabled: false)
|
||||
|
||||
render_inline Admin::Budgets::IndexComponent.new(Budget.page(1))
|
||||
|
||||
expect(page.find("tr", text: "Not enabled phase")).to have_content "0/8"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user