From 1495b2bb85b5a3de0daf4cfbf2bd46b66dec1bb4 Mon Sep 17 00:00:00 2001 From: Benjamin-Couey Date: Mon, 1 Sep 2025 14:08:20 -0700 Subject: [PATCH 1/2] Fixed deadline_date_controller incorrectly using RRule library, causing next reminder calculation to change based on time of day and time zone --- app/javascript/controllers/deadline_day_controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/controllers/deadline_day_controller.js b/app/javascript/controllers/deadline_day_controller.js index ea3ff2c871..eb1d0fbeb5 100644 --- a/app/javascript/controllers/deadline_day_controller.js +++ b/app/javascript/controllers/deadline_day_controller.js @@ -47,7 +47,7 @@ export default class extends Controller { if (this.byDayOfMonthTarget.checked && this.dayOfMonthTarget.value) { const rule = new RRule({ - dtstart: today, + dtstart: new Date(Date.UTC(today.getFullYear(), today.getMonth(), today.getDate(), 12)), freq: RRule.MONTHLY, interval: monthlyInterval, bymonthday: parseInt(this.dayOfMonthTarget.value), @@ -57,7 +57,7 @@ export default class extends Controller { } if (this.byDayOfWeekTarget.checked && this.everyNthDayTarget.value && (this.dayOfWeekTarget.value)) { const rule = new RRule({ - dtstart: today, + dtstart: new Date(Date.UTC(today.getFullYear(), today.getMonth(), today.getDate(), 12)), freq: RRule.MONTHLY, interval: monthlyInterval, byweekday: WEEKDAY_NUM_TO_OBJ[ parseInt(this.dayOfWeekTarget.value) ].nth( parseInt(this.everyNthDayTarget.value) ), From 15b7005d214e4e242f3b210d3662431f2a9a47ad Mon Sep 17 00:00:00 2001 From: Benjamin-Couey Date: Mon, 1 Sep 2025 14:13:06 -0700 Subject: [PATCH 2/2] Added disclaimer clarifying that tests could change behavior based on when they are run --- spec/support/deadline_day_fields_shared_example.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/support/deadline_day_fields_shared_example.rb b/spec/support/deadline_day_fields_shared_example.rb index 48843e3892..8b34b14389 100644 --- a/spec/support/deadline_day_fields_shared_example.rb +++ b/spec/support/deadline_day_fields_shared_example.rb @@ -74,6 +74,11 @@ def safe_subtract_days(date, num) expect(page).to have_content("Deadline day must be between 1 and 28") end + # These tests make assertions about the dates calculated by the javascript in deadline_day_controller.js + # Because we currently don't have a great way of spoofing the date the headless browser sees during tests, they + # cannot effectively set the date for the tests (like with travel_to) and have to make due with the actual datetime + # of whenever the test is run. To the best of my knowledge, the tests are sound but be aware that they could + # pass or fail based on when they are run! describe "reported reminder and deadline dates" do context "when the reminder is a day of the month" do before do