-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3369 from alphagov/timed-updates
Timed updates
- Loading branch information
Showing
6 changed files
with
35 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module TimedUpdateHelper | ||
def before_update_time?(year:, month:, day:, hour:, minute:) | ||
Time.zone.now.before? Time.zone.local(year, month, day, hour, minute) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require "test_helper" | ||
|
||
class TimedUpdateHelperTest < ActiveSupport::TestCase | ||
include TimedUpdateHelper | ||
|
||
test "#before_update_time? returns true if we haven't reached the requested time yet" do | ||
Timecop.freeze(2024, 6, 17, 23, 59) | ||
assert before_update_time?(year: 2024, month: 6, day: 18, hour: 0, minute: 0) | ||
end | ||
|
||
test "#before_update_time? returns false if we've reached the requested time" do | ||
Timecop.freeze(2024, 6, 18, 0, 0) | ||
assert_not before_update_time?(year: 2024, month: 6, day: 18, hour: 0, minute: 0) | ||
end | ||
|
||
test "#before_update_time? returns false if we've passed the requested time" do | ||
Timecop.freeze(2024, 6, 20, 10, 10) | ||
assert_not before_update_time?(year: 2024, month: 6, day: 18, hour: 0, minute: 0) | ||
end | ||
end |