From 61196bea8001a76188e26ac8d843f9d4c5d7d7ed Mon Sep 17 00:00:00 2001 From: James Williams Date: Tue, 11 Aug 2020 08:56:36 -0600 Subject: [PATCH] run content migration attachment creation through instfs test plan: * have instfs enabled * import a zip file into a course * the attachments should have instfs_uuids closes #LS-1285 Change-Id: I42e877e25dfcbd855bfc9e56b59cf969ea7d6ce0 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/244749 Tested-by: Service Cloud Jenkins Reviewed-by: Jeremy Stanley QA-Review: Robin Kuss Product-Review: James Williams --- lib/file_in_context.rb | 3 ++- spec/models/content_migration_spec.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/file_in_context.rb b/lib/file_in_context.rb index c516b28305c..7c1e66da097 100644 --- a/lib/file_in_context.rb +++ b/lib/file_in_context.rb @@ -49,7 +49,8 @@ class FileInContext uploaded_data = Rack::Test::UploadedFile.new(filename, Attachment.mimetype(explicit_filename || filename)) - @attachment = Attachment.new(:context => context, :uploaded_data => uploaded_data, :display_name => display_name, :folder => folder) + @attachment = Attachment.new(:context => context, :display_name => display_name, :folder => folder) + Attachments::Storage.store_for_attachment(@attachment, uploaded_data) @attachment.filename = explicit_filename if explicit_filename @attachment.set_publish_state_for_usage_rights @attachment.save! diff --git a/spec/models/content_migration_spec.rb b/spec/models/content_migration_spec.rb index 7e78f41f62d..d00ee09be85 100644 --- a/spec/models/content_migration_spec.rb +++ b/spec/models/content_migration_spec.rb @@ -217,6 +217,17 @@ describe ContentMigration do test_zip_import(@course, cm) end + it "should go through instfs if enabled" do + cm = setup_zip_import(@course) + allow(InstFS).to receive(:enabled?).and_return(true) + @uuid = "1234-abcd" + allow(InstFS).to receive(:direct_upload).and_return(@uuid) + + test_zip_import(@course, cm) + attachment = @course.attachments.last + expect(attachment.instfs_uuid).to eq(@uuid) + end + it "should import into a user" do cm = setup_zip_import(@user) test_zip_import(@user, cm)