add duedatecacher run when adhoc overrides changed via api
This patchset adds a call to DueDateCacher.recompute to Assignment#run_if_overrides_changed! to avoid situations where either cleanup callbacks are skipped or other due date changes that would change the cached due date. fixes GRADE-677 test plan: - Create a course with at least 2 users - Create an assignment and assign it to just 2 of the users - Visit the gradebook and note both students are able to be graded - Return to the assignment settings and remove one of those users from the override - Visit the gradebook and note only the still assigned student is able to be graded Change-Id: I3cedd13ecedcc1cb785e2a70589fd79bef48802d Reviewed-on: https://gerrit.instructure.com/134028 Tested-by: Jenkins Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Reviewed-by: Spencer Olson <solson@instructure.com> QA-Review: Indira Pai <ipai@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
This commit is contained in:
parent
6718b0bf0e
commit
1996c39274
|
@ -2551,7 +2551,9 @@ class Assignment < ActiveRecord::Base
|
|||
def run_if_overrides_changed!(student_ids=nil)
|
||||
relocked_modules = []
|
||||
self.relock_modules!(relocked_modules, student_ids)
|
||||
each_submission_type { |submission| submission.relock_modules!(relocked_modules, student_ids) if submission }
|
||||
each_submission_type { |submission| submission&.relock_modules!(relocked_modules, student_ids)}
|
||||
|
||||
DueDateCacher.recompute(self)
|
||||
|
||||
if only_visible_to_overrides?
|
||||
Rails.logger.info "GRADES: recalculating because assignment overrides on #{global_id} changed."
|
||||
|
|
|
@ -301,6 +301,7 @@ module Api::V1::AssignmentOverride
|
|||
override.changed_student_ids.merge(defunct_student_ids)
|
||||
override.assignment_override_students.
|
||||
where(:user_id => defunct_student_ids.to_a).
|
||||
in_batches.
|
||||
delete_all
|
||||
end
|
||||
end
|
||||
|
|
|
@ -805,6 +805,20 @@ describe AssignmentOverridesController, type: :request do
|
|||
|
||||
end
|
||||
|
||||
it "runs DueDateCacher after changing overrides" do
|
||||
always_override_student = @student
|
||||
remove_override_student = student_in_course(:course => @course).user
|
||||
@override.assignment_override_students.create!(user: remove_override_student)
|
||||
@override.reload
|
||||
|
||||
expect(DueDateCacher).to receive(:recompute).with(@assignment)
|
||||
api_update_override(@course, @assignment, @override,
|
||||
:assignment_override => { :student_ids => [always_override_student.id] })
|
||||
|
||||
@override.reload
|
||||
expect(@override.assignment_override_students.map(&:user_id)).to eq([always_override_student.id])
|
||||
end
|
||||
|
||||
it "should allow changing the title" do
|
||||
@new_title = "new #{@title}"
|
||||
api_update_override(@course, @assignment, @override, :assignment_override => { :title => @new_title })
|
||||
|
|
Loading…
Reference in New Issue