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 <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
James Williams 2020-08-11 08:56:36 -06:00
parent e59ab3875e
commit 61196bea80
2 changed files with 13 additions and 1 deletions

View File

@ -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!

View File

@ -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)