The personal finance app for everyone (by everyone)
Ruby
Avoid rendering unknown cash bridge (#3868)
Sure Admin (bot)ff4e39653c47
diff --git a/app/helpers/bills_helper.rb b/app/helpers/bills_helper.rbindex 3d0a9a43c6..df5febe322 100644--- a/app/helpers/bills_helper.rb+++ b/app/helpers/bills_helper.rb@@ -77,7 +77,8 @@ module BillsHelper# The paycheck plan split into what the page renders: the leading no-income# bridge window (reported above the timeline, never inside it), the real# periods, and which of the two bridge states applies -- short earns the- # warning, covered-with-items earns the quiet strip.+ # warning, covered-with-items earns the quiet strip. An unknown cash balance+ # proves neither state, so it must not render either cash-dependent partial.def paycheck_plan_sections(plan)return {} if plan.blank?@@ -87,7 +88,7 @@ module BillsHelperbridge: bridge,periods: plan.reject(&:bridge?),shortfall: bridge&.short? ? bridge : nil,- bridge_note: bridge && !bridge.short? && bridge.items.any? ? bridge : nil+ bridge_note: bridge && bridge.cash_on_hand.present? && !bridge.short? && bridge.items.any? ? bridge : nil}enddiff --git a/test/helpers/bills_helper_test.rb b/test/helpers/bills_helper_test.rbindex 25047fa15a..0acbb08ffd 100644--- a/test/helpers/bills_helper_test.rb+++ b/test/helpers/bills_helper_test.rb@@ -467,6 +467,16 @@ class BillsHelperTest < ActionView::TestCaseassert_equal covered, sections[:bridge_note]end+ test "a bridge with unknown cash renders neither cash-dependent state" do+ unknown = build_period(income: 0, due: 50, reserved: 0, leading: true,+ cash_on_hand: nil, items: [ :a_bill ])++ sections = paycheck_plan_sections([ unknown ])++ assert_nil sections[:shortfall]+ assert_nil sections[:bridge_note]+ end+test "no plan yields empty sections" doassert_empty paycheck_plan_sections(nil)end