Fill AssignmentOverride and AOStudent with quiz as context

closes INTEROP-6073
flag=none

Test plan
- Have an adhoc override on a non-assignment quiz
- (Also an assignment quiz, but I'm pretty sure those
  are linked to the assignment, but check)
- Remove the root account ids for both
- Run DataFixup::PopulateRootAccountIdOnModels.run
  and ensure both get their root account ids filled

Change-Id: I5effe4850c8213ffa3f658691f8a1091673d6434
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/244823
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Evan Battaglia <ebattaglia@instructure.com>
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
Mysti Lilla 2020-08-11 19:44:13 -06:00 committed by Weston Dransfield
parent ebcb12c309
commit ca90cee58a
2 changed files with 25 additions and 9 deletions

View File

@ -63,8 +63,8 @@ module DataFixup::PopulateRootAccountIdOnModels
AssessmentQuestionBank => :context,
AssetUserAccess => [:context_course, :context_group, {context_account: [:root_account_id, :id]}],
AssignmentGroup => :context,
AssignmentOverride => :assignment,
AssignmentOverrideStudent => :assignment,
AssignmentOverride => [:assignment, :quiz],
AssignmentOverrideStudent => [:assignment, :quiz],
AttachmentAssociation => %i[course group submission attachment], # attachment is last, only used if context is a ConversationMessage
CalendarEvent => [:context_course, :context_group, :context_course_section],
CommunicationChannel => [], # has override

View File

@ -168,21 +168,37 @@ describe DataFixup::PopulateRootAccountIdOnModels do
it 'should populate the root_account_id on AssignmentOverride' do
assignment_model(course: @course)
@course.enroll_student(@user)
create_adhoc_override_for_assignment(@assignment, @user)
@override.update_columns(root_account_id: nil)
expect(@override.attributes["root_account_id"]).to be nil
override1 = create_adhoc_override_for_assignment(@assignment, @user)
override1.update_columns(root_account_id: nil)
expect(override1.attributes["root_account_id"]).to be nil
quiz_model(course: @course)
override2 = create_adhoc_override_for_assignment(@quiz, @user)
override2.update_columns(root_account_id: nil)
expect(override2.attributes["root_account_id"]).to be nil
DataFixup::PopulateRootAccountIdOnModels.run
expect(@override.reload.root_account_id).to eq @course.root_account_id
expect(override1.reload.attributes["root_account_id"]).to eq @course.root_account_id
expect(override2.reload.attributes["root_account_id"]).to eq @course.root_account_id
end
it 'should populate the root_account_id on AssignmentOverrideStudent' do
assignment_model(course: @course)
@course.enroll_student(@user)
assignment_model(course: @course)
create_adhoc_override_for_assignment(@assignment, @user)
@override_student.update_columns(root_account_id: nil)
expect(@override_student.root_account_id).to be nil
os1 = @override_student
expect(os1.root_account_id).to be nil
quiz_model(course: @course)
create_adhoc_override_for_assignment(@quiz, @user)
@override_student.update_columns(root_account_id: nil)
os2 = @override_student
expect(os2.root_account_id).to be nil
DataFixup::PopulateRootAccountIdOnModels.run
expect(@override_student.reload.root_account_id).to eq @course.root_account_id
expect(os1.reload.root_account_id).to eq @course.root_account_id
expect(os2.reload.root_account_id).to eq @course.root_account_id
end
context 'with AttachmentAssociation with a non-ConversationMessage context' do