The personal finance app for everyone (by everyone)
Ruby
Hide the bills month pulse on a page of only paused bills (#3923)
Guillem Arias Fauste6875725f5f0e
diff --git a/app/views/bills/index.html.erb b/app/views/bills/index.html.erbindex e302636020..13d7aa4045 100644--- a/app/views/bills/index.html.erb+++ b/app/views/bills/index.html.erb@@ -24,8 +24,9 @@<%# With no bill rows the pulse is a card of dashes and zeros, and theprompts would start a chat about bills that don't exist. Suggestions- don't count: they aren't bills yet, and the pulse can't total them. %>- <% unless bill_rows_empty %>+ don't count: they aren't bills yet, and the pulse can't total them.+ Nor do Dormant rows: paused bills owe nothing this month. %>+ <% unless [ @overdue, @month_rows, @later ].all?(&:empty?) %><%= render "bills/month_pulse" %><%= render "bills/ai_prompts", prompts: %w[due_before_paycheck subscriptions_up monthly_subscriptions] %>diff --git a/test/controllers/bills_controller_test.rb b/test/controllers/bills_controller_test.rbindex 8445bfa53a..e196125f61 100644--- a/test/controllers/bills_controller_test.rb+++ b/test/controllers/bills_controller_test.rb@@ -1642,6 +1642,62 @@ class BillsControllerTest < ActionDispatch::IntegrationTestassert_no_match I18n.t("bills.index.empty.title"), response.bodyend+ # Dormant rows don't feed the pulse, so a page of paused bills would show+ # a card of zeros and chips asking about bills nobody is paying.+ test "a page of only paused bills shows the dormant section without the month pulse or the AI prompts" do+ Provider::Registry.stubs(:preferred_llm_provider).returns(Object.new)+ overdue_day = 5.days.ago.to_date+ bill = create_bill(name: "Paused gym", amount: 40,+ expected_day_of_month: overdue_day.day,+ last_occurrence_date: 2.months.ago.to_date,+ next_expected_date: overdue_day)+ bill.mark_inactive!+ assert bill.recurring_occurrences.open_status.exists?, "the paused bill keeps its overdue occurrence"++ get bills_url+ assert_response :success+ assert_match "Paused gym", response.body+ assert_match I18n.t("bills.index.dormant"), response.body+ assert_no_match I18n.t("bills.month_pulse.left_to_pay"), response.body+ assert_no_match "due before my next paycheck", response.body+ assert_no_match I18n.t("bills.ai_prompts.subscriptions_up"), response.body+ end++ test "a page of only bills due after this month keeps the month pulse" do+ next_month = Date.current.next_month.beginning_of_month + 4+ # Manual and anchored next month, or generation also writes this month's+ # cycle and the pulse stays up without the later row.+ create_bill(name: "Next month rent", amount: 900, manual: true, anchor_date: next_month,+ expected_day_of_month: next_month.day,+ next_expected_date: next_month)++ get bills_url+ assert_response :success+ assert_empty @controller.view_assigns["overdue"] + @controller.view_assigns["month_rows"],+ "premise: the later row is the only one"+ assert_match I18n.t("bills.index.later"), response.body+ assert_match I18n.t("bills.month_pulse.left_to_pay"), response.body+ end++ test "a page whose only pulse row is a paid one keeps the month pulse" do+ bill = create_bill(name: "Water Co", amount: 30)+ settled = bill.recurring_occurrences.order(:due_on).first+ entry = accounts(:depository).entries.create!(+ date: settled.due_on, amount: 30, currency: "USD",+ name: "WATER CO", entryable: Transaction.new+ )+ RecurringTransaction::Allocator.new(settled).allocate!(amount: "30", entry: entry)+ assert settled.reload.paid?+ # Paused after paying, so nothing is open: the paid row is all the pulse has.+ bill.mark_inactive!++ get bills_url+ assert_response :success+ assert_match "Water Co", response.body+ assert_no_match I18n.t("bills.index.dormant"), response.body+ assert_match I18n.t("bills.month_pulse.left_to_pay"), response.body+ end+test "AI chips and the review button need both consent and a provider" do# The chips only render over bill rows.create_bill(name: "Power Co", amount: 80)