Send resource_map when importing as quizzes next
This allows us to perform link migration when migrating from old to new quizzes during an import. closes LF-465 flag=content_migration_asset_map_v2 flag=new_quizzes_migration Test Plan: - Specs pass - Monitor your local canvas live events with the tail_kinesis script - Make a course export from a course with no new quizzes. - Using that course export, Perform a course import with `import as new quizzes` checked. - Observe in the live event stream that the resource_map_url is populated in the content_migration_completed live event. - Perform another import into an new course without checking `import as new quizzes`. - Observe in the live event stream that the resource_map_url is not populated. Change-Id: Iaec7d0618e88c4785f9cb7061801dbbfbb82ae90 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/322320 Reviewed-by: Paul Gray <paul.gray@instructure.com> QA-Review: James Logan <james.logan@instructure.com> Product-Review: Mysti Lilla <mysti@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
parent
2c9502053a
commit
bad8bcac9c
|
@ -682,7 +682,9 @@ module Canvas::LiveEvents
|
|||
context = content_migration.context
|
||||
import_quizzes_next =
|
||||
content_migration.migration_settings&.[](:import_quizzes_next) == true
|
||||
need_resource_map = content_migration.source_course&.has_new_quizzes?
|
||||
link_migration_during_import = import_quizzes_next && content_migration.asset_map_v2?
|
||||
need_resource_map = content_migration.source_course&.has_new_quizzes? || link_migration_during_import
|
||||
|
||||
payload = {
|
||||
content_migration_id: content_migration.global_id,
|
||||
context_id: context.global_id,
|
||||
|
|
|
@ -1394,8 +1394,8 @@ describe Canvas::LiveEvents do
|
|||
migration.migration_settings[:import_quizzes_next] = true
|
||||
course.lti_context_id = "abc"
|
||||
source_course.lti_context_id = "def"
|
||||
expect(source_course).to receive(:has_new_quizzes?).and_return(true)
|
||||
expect(migration).to receive(:file_download_url).and_return("http://example.com/resource_map.json")
|
||||
allow(source_course).to receive(:has_new_quizzes?).and_return(true)
|
||||
allow(migration).to receive(:file_download_url).and_return("http://example.com/resource_map.json")
|
||||
end
|
||||
|
||||
it "sent events with expected payload" do
|
||||
|
@ -1425,6 +1425,45 @@ describe Canvas::LiveEvents do
|
|||
|
||||
Canvas::LiveEvents.content_migration_completed(migration)
|
||||
end
|
||||
|
||||
describe "resource map property" do
|
||||
before do
|
||||
allow(migration).to receive(:asset_map_v2?).and_return(true)
|
||||
allow(source_course).to receive(:has_new_quizzes?).and_return(false)
|
||||
end
|
||||
|
||||
describe "the resource map is not needed" do
|
||||
before do
|
||||
migration.migration_settings[:import_quizzes_next] = false
|
||||
end
|
||||
|
||||
it "does not send the resource map" do
|
||||
expect_event(
|
||||
"content_migration_completed",
|
||||
hash_not_including(:resource_map_url),
|
||||
hash_including(context_id: course.global_id.to_s)
|
||||
).once
|
||||
|
||||
Canvas::LiveEvents.content_migration_completed(migration)
|
||||
end
|
||||
end
|
||||
|
||||
describe "importing new quizzes with link migration" do
|
||||
before do
|
||||
migration.migration_settings[:import_quizzes_next] = true
|
||||
end
|
||||
|
||||
it "does not send the resource map" do
|
||||
expect_event(
|
||||
"content_migration_completed",
|
||||
hash_including(resource_map_url: "http://example.com/resource_map.json"),
|
||||
hash_including(context_id: course.global_id.to_s)
|
||||
).once
|
||||
|
||||
Canvas::LiveEvents.content_migration_completed(migration)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe ".course_section_created" do
|
||||
|
|
Loading…
Reference in New Issue