blueprint: fix syncing files when folders deleted downstream
test plan: 1. Create a blueprint course with a folder and a file, sync to an associated course 2. Delete the folder in the associated course 3. Rename the folder in the parent, add a new file, sync it 4. The sync should succeed 5. The folder should be recreated in the associated course containing only the newly added file from step 3 flag = none fixes LS-2047 Change-Id: I7753f2459e90bf5e1be47313157824513d7de4d9 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/261070 Reviewed-by: Weston Dransfield <wdransfield@instructure.com> Reviewed-by: Eric Saupe <eric.saupe@instructure.com> QA-Review: Eric Saupe <eric.saupe@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
6820d429cc
commit
bb70052cd1
|
@ -73,7 +73,7 @@ class MasterCourses::FolderHelper
|
|||
dest_folder.send("#{attr}=", source_folder.send(attr))
|
||||
end
|
||||
end
|
||||
dest_folder.save! if dest_folder.changed?
|
||||
dest_folder.save! if dest_folder&.changed?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1794,6 +1794,36 @@ describe MasterCourses::MasterMigration do
|
|||
expect(@copy_to.folders.where(:name => "parent RENAMED").first.locked).to eq true
|
||||
end
|
||||
|
||||
it "deals with a deleted folder being changed upstream" do
|
||||
blueprint_folder = nil
|
||||
att_tag = nil
|
||||
@copy_to = course_factory
|
||||
@sub = @template.add_child_course!(@copy_to)
|
||||
|
||||
Timecop.travel(10.minutes.ago) do
|
||||
blueprint_folder = Folder.root_folders(@copy_from).first.sub_folders.create!(:name => "folder", :context => @copy_from)
|
||||
att = Attachment.create!(:filename => 'file.txt', :uploaded_data => StringIO.new('1'), :folder => blueprint_folder, :context => @copy_from)
|
||||
att_tag = @template.create_content_tag_for!(att)
|
||||
run_master_migration
|
||||
end
|
||||
|
||||
att2_tag = nil
|
||||
Timecop.travel(5.minutes.ago) do
|
||||
associated_folder = @copy_to.folders.where(cloned_item_id: blueprint_folder.cloned_item_id).take
|
||||
associated_folder.destroy
|
||||
|
||||
blueprint_folder.update(:name => "folder RENAMED", :locked => true)
|
||||
att2 = Attachment.create!(:filename => 'file2.txt', :uploaded_data => StringIO.new('2'), :folder => blueprint_folder, :context => @copy_from)
|
||||
att2_tag = @template.create_content_tag_for!(att2)
|
||||
end
|
||||
|
||||
m = run_master_migration
|
||||
expect(m).to be_completed
|
||||
|
||||
copied_att = @copy_to.attachments.where(:migration_id => att2_tag.migration_id).first
|
||||
expect(copied_att.full_path).to eq "course files/folder RENAMED/file2.txt"
|
||||
end
|
||||
|
||||
it "syncs moved folders" do
|
||||
folder_A = Folder.root_folders(@copy_from).first.sub_folders.create!(name: 'A', context: @copy_from)
|
||||
folder_B = Folder.root_folders(@copy_from).first.sub_folders.create!(name: 'B', context: @copy_from)
|
||||
|
|
Loading…
Reference in New Issue