Skip to content

Commit

Permalink
fix duedatecacher crashing when dealing with bc dates
Browse files Browse the repository at this point in the history
closes EVAL-2499
flag=none

Test Plan:
- Smoke test creating assignments with various due dates and ensure
  the generated submissions have the correct cached_due_date on them.

Change-Id: I9a7792d1f49b0cef13334cbf94870f7518fc59ce
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/297120
Tested-by: Service Cloud Jenkins <[email protected]>
Product-Review: Keith Garner <[email protected]>
QA-Review: Kai Bjorkman <[email protected]>
Reviewed-by: Kai Bjorkman <[email protected]>
Reviewed-by: Paulo Chaves <[email protected]>
  • Loading branch information
spencerolson committed Aug 23, 2022
1 parent 262201b commit 7a68b73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/due_date_cacher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def recompute

student_due_dates.each_key do |student_id|
submission_info = student_due_dates[student_id]
due_date = submission_info[:due_at] ? "'#{submission_info[:due_at].iso8601}'::timestamptz" : "NULL"
due_date = submission_info[:due_at] ? "'#{ActiveRecord::Base.connection.quoted_date(submission_info[:due_at].change(usec: 0))}'::timestamptz" : "NULL"
grading_period_id = submission_info[:grading_period_id] || "NULL"

anonymous_id = Anonymity.generate_id(existing_ids: existing_anonymous_ids)
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/due_date_cacher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,14 @@
}.from(0).to(1)
end

it "doesn't blow up when handling BC dates" do
bc_date = 5000.years.ago
@assignment.update_columns(due_at: bc_date)
expect { cacher.recompute }.to change {
Submission.find_by(assignment: @assignment, user: @student)&.cached_due_date
}.from(nil).to(bc_date.change(usec: 0))
end

it "deletes submissions for enrollments that are deleted" do
@course.student_enrollments.update_all(workflow_state: "deleted")

Expand Down

0 comments on commit 7a68b73

Please sign in to comment.