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) ), 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