-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle edge cases for EvidenceSubmissionWindowTasks #15598
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7c3d163
Handle edge cases for EvidenceSubmissionWindowTasks
hschallhorn 996859a
Remove focus
hschallhorn efca5fc
Merge branch 'master' into hschallhorn/15245-task-timer-edge-cases
hschallhorn e50b415
Merge branch 'master' into hschallhorn/15245-task-timer-edge-cases
ajspotts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,21 @@ def timer_ends_at | |
end | ||
end | ||
|
||
class EdgeCaseTimedTask < Task | ||
include TimeableTask | ||
include CurrentDate | ||
|
||
def when_timer_ends; end | ||
|
||
def timer_ends_at | ||
# Our task timer job runs every hour. On occasion we create task timers that should have expired 3.99999 days ago | ||
# so they are not caught by the initial expired_without_processing? check when they are created. However, by the | ||
# time the job has run, the task should have expired 4.000001 days ago and falls out of our | ||
# expired_without_processing scope. See https://github.com/department-of-veterans-affairs/caseflow/issues/15245 | ||
4.days.ago + 30.minutes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. weird time stuff math. |
||
end | ||
end | ||
|
||
before do | ||
Timecop.freeze(now) | ||
end | ||
|
@@ -54,13 +69,26 @@ def timer_ends_at | |
expect(timers.first.submitted_at).to eq(task.timer_ends_at) | ||
end | ||
|
||
it "queues itself immediately when the delay is in the past" do | ||
task = OldTimedTask.create!(appeal: appeal, assigned_to: Bva.singleton) | ||
timers = TaskTimer.where(task: task) | ||
expect(timers.length).to eq(1) | ||
expect(timers.first.submitted_and_ready?).to eq(true) | ||
expect(timers.first.submitted_at).to eq(task.timer_ends_at) | ||
expect(timers.first.last_submitted_at).to eq(now) | ||
shared_examples "resets the timer" do | ||
it "queues itself immediately when the delay is in the past" do | ||
timers = TaskTimer.where(task: task) | ||
expect(timers.length).to eq(1) | ||
expect(timers.first.submitted_and_ready?).to eq(true) | ||
expect(timers.first.submitted_at).to eq(task.timer_ends_at) | ||
expect(timers.first.last_submitted_at).to eq(now) | ||
end | ||
end | ||
|
||
context "when the delay is in the past" do | ||
let(:task) { OldTimedTask.create!(appeal: appeal, assigned_to: Bva.singleton) } | ||
|
||
it_behaves_like "resets the timer" | ||
end | ||
|
||
context "when the delay is judge barely less than four days in the past" do | ||
let(:task) { EdgeCaseTimedTask.create!(appeal: appeal, assigned_to: Bva.singleton) } | ||
|
||
it_behaves_like "resets the timer" | ||
end | ||
|
||
context "when not correctly configured" do | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Called here:
caseflow/app/models/concerns/timeable_task.rb
Line 18 in 2eb2d81
ensures we catch any timers that will have slipped outside of this 4 day window by the time the next job is run