Skip to content

Commit fabc01a

Browse files
committed
fix double-_localstorage_ in Attachment#infer_namespace
test plan: - in a Rails development environment using local file storage, 1. use the content migration API to import the contents of a zip file into a folder in a course (use zip_file_importer as the migration_type, and set settings[folder_id] to the id of a folder in the course) 2. repeat step (1), but specify a different folder id 3. confirm the files can be downloaded and/or deleted in the second folder without a "Cannot find Account with id=0" error fixes CNVS-15726 Change-Id: Icb73efcf5b933f4a6b9dea9c0e2c884bfb82afd5 Reviewed-on: https://gerrit.instructure.com/41583 Reviewed-by: Jason Madsen <jmadsen@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Clare Strong <clare@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
1 parent c94f68c commit fabc01a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

app/models/attachment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def infer_namespace
426426
ns ||= self.context.account.file_namespace rescue nil
427427
if Rails.env.development? && Attachment.local_storage?
428428
ns ||= ""
429-
ns = "_localstorage_/#{ns}"
429+
ns = "_localstorage_/#{ns}" unless ns.start_with?('_localstorage_/')
430430
end
431431
ns = nil if ns && ns.empty?
432432
ns

spec/models/attachment_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,4 +1325,16 @@ def configure_crocodoc
13251325
end
13261326
end
13271327

1328+
describe "infer_namespace" do
1329+
it "should infer the correct namespace from the root attachment" do
1330+
local_storage!
1331+
Rails.env.stubs(:development?).returns(true)
1332+
course
1333+
a1 = attachment_model(context: @course, uploaded_data: default_uploaded_data)
1334+
a2 = attachment_model(context: @course, uploaded_data: default_uploaded_data)
1335+
a2.root_attachment.should eql(a1)
1336+
a2.namespace.should eql(a1.namespace)
1337+
end
1338+
end
1339+
13281340
end

0 commit comments

Comments
 (0)