From 1d1506f155b0b9f7d949c6fe9f0fb1149d1fce16 Mon Sep 17 00:00:00 2001 From: Jon Allured Date: Mon, 4 Nov 2024 21:09:01 -0600 Subject: [PATCH] Only render Weekend-specific chores on Weekends --- app/models/daily_packet/pdf_view.rb | 2 +- spec/models/daily_packet/pdf_view_spec.rb | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/models/daily_packet/pdf_view.rb b/app/models/daily_packet/pdf_view.rb index 2e939fe..c8afb45 100644 --- a/app/models/daily_packet/pdf_view.rb +++ b/app/models/daily_packet/pdf_view.rb @@ -102,7 +102,7 @@ def draw_chore_list_page font_size(20) do text "unload dishwasher" - text "collect laundry" + text "collect laundry" if daily_packet.built_on.saturday? || daily_packet.built_on.sunday? text "defrost meat" text "poop patrol" text "mow front" diff --git a/spec/models/daily_packet/pdf_view_spec.rb b/spec/models/daily_packet/pdf_view_spec.rb index df084f9..75b55e9 100644 --- a/spec/models/daily_packet/pdf_view_spec.rb +++ b/spec/models/daily_packet/pdf_view_spec.rb @@ -44,7 +44,6 @@ expect(page_three_strings).to eq([ "Chore List", "unload dishwasher", - "collect laundry", "defrost meat", "poop patrol", "mow front", @@ -67,4 +66,16 @@ expect(page_three_strings).to include "put out garbage cans" end end + + context "on a Saturday" do + let(:built_on) { Date.parse("2024-11-09") } + + it "renders the Saturday-specific chore" do + inspector = PDF::Inspector::Page.analyze(daily_packet.pdf_data) + + _, _, page_three_strings = inspector.pages.map { |page| page[:strings] } + + expect(page_three_strings).to include "collect laundry" + end + end end