Skip to content

Commit

Permalink
Only render summertime chores in summer
Browse files Browse the repository at this point in the history
  • Loading branch information
jonallured committed Nov 5, 2024
1 parent 1d1506f commit 4593198
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
13 changes: 9 additions & 4 deletions app/models/daily_packet/pdf_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,19 @@ def draw_chore_list_page

move_down 30

built_on_weekend = daily_packet.built_on.saturday? || daily_packet.built_on.sunday?
built_on_summertime = (4..10).cover?(daily_packet.built_on.month)

font_size(20) do
text "unload dishwasher"
text "collect laundry" if daily_packet.built_on.saturday? || daily_packet.built_on.sunday?
text "defrost meat"
text "poop patrol"
text "mow front"
text "mow back"
text "mow way back"
if built_on_weekend && built_on_summertime
text "poop patrol"
text "mow front"
text "mow back"
text "mow way back"
end
text "put out garbage cans" if daily_packet.built_on.monday?
text "wipe off kitchen table"
text "run dishwasher"
Expand Down
32 changes: 26 additions & 6 deletions spec/models/daily_packet/pdf_view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
"Chore List",
"unload dishwasher",
"defrost meat",
"poop patrol",
"mow front",
"mow back",
"mow way back",
"wipe off kitchen table",
"run dishwasher"
])
Expand All @@ -67,15 +63,39 @@
end
end

context "on a Saturday" do
context "on a Saturday in the fall" do
let(:built_on) { Date.parse("2024-11-09") }

it "renders the Saturday-specific chore" do
it "renders the Weekend-specific chore but not the summertime ones" 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"

expect(page_three_strings).to_not include(
"poop patrol",
"mow front",
"mow back",
"mow way back"
)
end
end

context "on a Saturday in the summer" do
let(:built_on) { Date.parse("2024-07-13") }

it "renders the summertime Weekend-specific chores" 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(
"poop patrol",
"mow front",
"mow back",
"mow way back"
)
end
end
end

0 comments on commit 4593198

Please sign in to comment.