spec: cleanup temp directories afterwards

Change-Id: I31d9c548faed196a970a3f24e1b251a87b08127b
Reviewed-on: https://gerrit.instructure.com/78451
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
James Williams 2016-05-02 10:34:44 -06:00
parent 3cefdc1fdb
commit 8efaeeb3a4
10 changed files with 51 additions and 70 deletions

View File

@ -7,7 +7,7 @@ describe Moodle::Converter do
before :once do before :once do
fixture_dir = File.dirname(__FILE__) + '/fixtures' fixture_dir = File.dirname(__FILE__) + '/fixtures'
archive_file_path = File.join(fixture_dir, 'moodle_backup_1_9.zip') archive_file_path = File.join(fixture_dir, 'moodle_backup_1_9.zip')
unzipped_file_path = File.join(File.dirname(archive_file_path), "moodle_#{File.basename(archive_file_path, '.zip')}", 'oi') unzipped_file_path = create_temp_dir!
converter = Moodle::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) converter = Moodle::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
converter.export converter.export
@ -15,11 +15,6 @@ describe Moodle::Converter do
@course = Course.create(:name => "test course") @course = Course.create(:name => "test course")
@cm = ContentMigration.create(:context => @course) @cm = ContentMigration.create(:context => @course)
Importers::CourseContentImporter.import_content(@course, @course_data, nil, @cm) Importers::CourseContentImporter.import_content(@course, @course_data, nil, @cm)
converter.delete_unzipped_archive
if File.exist?(unzipped_file_path)
FileUtils::rm_rf(unzipped_file_path)
end
end end
it "should successfully import the course" do it "should successfully import the course" do

View File

@ -5,14 +5,10 @@ describe Moodle::Converter do
before(:once) do before(:once) do
fixture_dir = File.dirname(__FILE__) + '/fixtures' fixture_dir = File.dirname(__FILE__) + '/fixtures'
archive_file_path = File.join(fixture_dir, 'moodle_backup_2.zip') archive_file_path = File.join(fixture_dir, 'moodle_backup_2.zip')
unzipped_file_path = File.join(File.dirname(archive_file_path), "moodle_#{File.basename(archive_file_path, '.zip')}", 'oi') unzipped_file_path = create_temp_dir!
converter = Moodle::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) converter = Moodle::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
converter.export converter.export
@base_course_data = converter.course.with_indifferent_access @base_course_data = converter.course.with_indifferent_access
converter.delete_unzipped_archive
if File.exist?(unzipped_file_path)
FileUtils::rm_rf(unzipped_file_path)
end
@course_data = Marshal.load(Marshal.dump(@base_course_data)) @course_data = Marshal.load(Marshal.dump(@base_course_data))
@course = Course.create(:name => "test course") @course = Course.create(:name => "test course")

View File

@ -3,12 +3,12 @@ if Qti.migration_executable
describe "QTI 1.2 zip" do describe "QTI 1.2 zip" do
before(:all) do before(:all) do
@archive_file_path = File.join(BASE_FIXTURE_DIR, 'qti', 'plain_qti.zip') @archive_file_path = File.join(BASE_FIXTURE_DIR, 'qti', 'plain_qti.zip')
unzipped_file_path = File.join(File.dirname(@archive_file_path), "qti_#{File.basename(@archive_file_path, '.zip')}", 'oi') unzipped_file_path = create_temp_dir!
@dir = File.join(File.dirname(@archive_file_path), "qti_plain_qti") @dir = create_temp_dir!
@course = Course.create!(:name => 'tester') @course = Course.create!(:name => 'tester')
@migration = ContentMigration.create(:context => @course) @migration = ContentMigration.create(:context => @course)
@converter = Qti::Converter.new(:export_archive_path=>@archive_file_path, :base_download_dir=>unzipped_file_path, :content_migration => @migration) @converter = Qti::Converter.new(:export_archive_path=>@archive_file_path, :base_download_dir=>unzipped_file_path, :content_migration => @migration)
@converter.export @converter.export
@course_data = @converter.course.with_indifferent_access @course_data = @converter.course.with_indifferent_access
@ -18,15 +18,11 @@ if Qti.migration_executable
@migration.set_default_settings @migration.set_default_settings
@migration.migration_settings[:migration_ids_to_import] = {:copy=>{}} @migration.migration_settings[:migration_ids_to_import] = {:copy=>{}}
@migration.migration_settings[:files_import_root_path] = @course_data[:files_import_root_path] @migration.migration_settings[:files_import_root_path] = @course_data[:files_import_root_path]
Importers::CourseContentImporter.import_content(@course, @course_data, nil, @migration) Importers::CourseContentImporter.import_content(@course, @course_data, nil, @migration)
end end
after(:all) do after(:all) do
truncate_all_tables truncate_all_tables
@converter.delete_unzipped_archive
if File.exist?(@dir)
FileUtils::rm_rf(@dir)
end
end end
it "should convert the assessments" do it "should convert the assessments" do
@ -50,9 +46,8 @@ if Qti.migration_executable
end end
it "should have file paths" do it "should have file paths" do
expect(@course_data[:overview_file_path].index("oi/overview.json")).not_to be_nil expect(@course_data[:overview_file_path].index("/overview.json")).not_to be_nil
expect(@course_data[:export_folder_path].index('spec_canvas/fixtures/qti/qti_plain_qti/oi')).not_to be_nil expect(@course_data[:full_export_file_path].index('course_export.json')).not_to be_nil
expect(@course_data[:full_export_file_path].index('spec_canvas/fixtures/qti/qti_plain_qti/oi/course_export.json')).not_to be_nil
end end
it "should import the included files" do it "should import the included files" do
@ -70,28 +65,28 @@ if Qti.migration_executable
c_att = @course.attachments.where(migration_id: "4d348a246af616c7d9a7d403367c1a30").first c_att = @course.attachments.where(migration_id: "4d348a246af616c7d9a7d403367c1a30").first
att = aq.attachments.where(migration_id: CC::CCHelper.create_key(c_att)).first att = aq.attachments.where(migration_id: CC::CCHelper.create_key(c_att)).first
expect(aq.question_data["question_text"]).to match %r{files/#{att.id}/download} expect(aq.question_data["question_text"]).to match %r{files/#{att.id}/download}
aq = @course.assessment_questions.where(migration_id: "QUE_1007").first aq = @course.assessment_questions.where(migration_id: "QUE_1007").first
c_att = @course.attachments.where(migration_id: "f3e5ead7f6e1b25a46a4145100566821").first c_att = @course.attachments.where(migration_id: "f3e5ead7f6e1b25a46a4145100566821").first
att = aq.attachments.where(migration_id: CC::CCHelper.create_key(c_att)).first att = aq.attachments.where(migration_id: CC::CCHelper.create_key(c_att)).first
expect(aq.question_data["question_text"]).to match %r{files/#{att.id}/download} expect(aq.question_data["question_text"]).to match %r{files/#{att.id}/download}
aq = @course.assessment_questions.where(migration_id: "QUE_1014").first aq = @course.assessment_questions.where(migration_id: "QUE_1014").first
c_att = @course.attachments.where(migration_id: "d2b5ca33bd970f64a6301fa75ae2eb22").first c_att = @course.attachments.where(migration_id: "d2b5ca33bd970f64a6301fa75ae2eb22").first
att = aq.attachments.where(migration_id: CC::CCHelper.create_key(c_att)).first att = aq.attachments.where(migration_id: CC::CCHelper.create_key(c_att)).first
expect(aq.question_data["question_text"]).to match %r{files/#{att.id}/download} expect(aq.question_data["question_text"]).to match %r{files/#{att.id}/download}
aq = @course.assessment_questions.where(migration_id: "QUE_1053").first aq = @course.assessment_questions.where(migration_id: "QUE_1053").first
c_att = @course.attachments.where(migration_id: "c16566de1661613ef9e5517ec69c25a1").first c_att = @course.attachments.where(migration_id: "c16566de1661613ef9e5517ec69c25a1").first
att = aq.attachments.where(migration_id: CC::CCHelper.create_key(c_att)).first att = aq.attachments.where(migration_id: CC::CCHelper.create_key(c_att)).first
expect(aq.question_data["question_text"]).to match %r{files/#{att.id}/download} expect(aq.question_data["question_text"]).to match %r{files/#{att.id}/download}
end end
it "should hide the quiz directory" do it "should hide the quiz directory" do
folder = @course.folders.where(name: Canvas::Migration::MigratorHelper::QUIZ_FILE_DIRECTORY).first folder = @course.folders.where(name: Canvas::Migration::MigratorHelper::QUIZ_FILE_DIRECTORY).first
expect(folder.hidden?).to be_truthy expect(folder.hidden?).to be_truthy
end end
it "should use new attachments for imports with same file names" do it "should use new attachments for imports with same file names" do
# run a second migration and check that there are different attachments on the questions # run a second migration and check that there are different attachments on the questions
migration = ContentMigration.create(:context => @course) migration = ContentMigration.create(:context => @course)
@ -104,13 +99,13 @@ if Qti.migration_executable
migration.migration_settings[:files_import_root_path] = course_data[:files_import_root_path] migration.migration_settings[:files_import_root_path] = course_data[:files_import_root_path]
migration.migration_settings[:id_prepender] = 'test2' migration.migration_settings[:id_prepender] = 'test2'
Importers::CourseContentImporter.import_content(@course, course_data, nil, migration) Importers::CourseContentImporter.import_content(@course, course_data, nil, migration)
# Check the first import # Check the first import
aq = @course.assessment_questions.where(migration_id: "QUE_1003").first aq = @course.assessment_questions.where(migration_id: "QUE_1003").first
c_att = @course.attachments.where(migration_id: "4d348a246af616c7d9a7d403367c1a30").first c_att = @course.attachments.where(migration_id: "4d348a246af616c7d9a7d403367c1a30").first
att = aq.attachments.where(migration_id: CC::CCHelper.create_key(c_att)).first att = aq.attachments.where(migration_id: CC::CCHelper.create_key(c_att)).first
expect(aq.question_data["question_text"]).to match %r{files/#{att.id}/download} expect(aq.question_data["question_text"]).to match %r{files/#{att.id}/download}
# check the second import # check the second import
aq = @course.assessment_questions.where(migration_id: "test2_QUE_1003").first aq = @course.assessment_questions.where(migration_id: "test2_QUE_1003").first
c_att = @course.attachments.where(migration_id: "test2_4d348a246af616c7d9a7d403367c1a30").first c_att = @course.attachments.where(migration_id: "test2_4d348a246af616c7d9a7d403367c1a30").first

View File

@ -5,8 +5,8 @@ if Qti.migration_executable
describe "QTI 2.1 zip" do describe "QTI 2.1 zip" do
def import_fixture(filename) def import_fixture(filename)
archive_file_path = File.join(BASE_FIXTURE_DIR, 'qti2_conformance', filename) archive_file_path = File.join(BASE_FIXTURE_DIR, 'qti2_conformance', filename)
unzipped_file_path = File.join(File.dirname(archive_file_path), "qti_#{File.basename(archive_file_path, '.zip')}", 'oi') unzipped_file_path = create_temp_dir!
@export_folder = File.join(File.dirname(archive_file_path), "qti_#{filename}".gsub('.zip', '')) @export_folder = create_temp_dir!
@course = Course.create!(:name => filename) @course = Course.create!(:name => filename)
@migration = ContentMigration.create(:context => @course) @migration = ContentMigration.create(:context => @course)
@ -23,12 +23,6 @@ if Qti.migration_executable
expect(@migration.migration_issues).to be_empty expect(@migration.migration_issues).to be_empty
end end
after :each do
if @export_folder && File.exist?(@export_folder)
FileUtils::rm_rf(@export_folder)
end
end
it "should import VE_IP_01" do it "should import VE_IP_01" do
import_fixture('VE_IP_01.zip') import_fixture('VE_IP_01.zip')
expect(@course.quizzes.count).to eq 0 expect(@course.quizzes.count).to eq 0

View File

@ -3,14 +3,10 @@ if Qti.migration_executable
describe "QTI 2.1 zip" do describe "QTI 2.1 zip" do
before(:all) do before(:all) do
archive_file_path = File.join(BASE_FIXTURE_DIR, 'qti', 'qti_2_1.zip') archive_file_path = File.join(BASE_FIXTURE_DIR, 'qti', 'qti_2_1.zip')
unzipped_file_path = File.join(File.dirname(archive_file_path), "qti_#{File.basename(archive_file_path, '.zip')}", 'oi') unzipped_file_path = create_temp_dir!
export_folder = File.join(File.dirname(archive_file_path), "qti_qti_2_1") export_folder = create_temp_dir!
@exporter = Qti::Converter.new(:export_archive_path=>archive_file_path, :base_download_dir=>unzipped_file_path) @exporter = Qti::Converter.new(:export_archive_path=>archive_file_path, :base_download_dir=>unzipped_file_path)
@exporter.export @exporter.export
@exporter.delete_unzipped_archive
if File.exist?(export_folder)
FileUtils::rm_rf(export_folder)
end
end end
it "should convert the questions" do it "should convert the questions" do
@ -18,9 +14,8 @@ describe "QTI 2.1 zip" do
end end
it "should have file paths" do it "should have file paths" do
expect(@exporter.course[:overview_file_path].index("oi/overview.json")).not_to be_nil expect(@exporter.course[:overview_file_path].index("overview.json")).not_to be_nil
expect(@exporter.course[:export_folder_path].index('spec_canvas/fixtures/qti/qti_qti_2_1/oi')).not_to be_nil expect(@exporter.course[:full_export_file_path].index('course_export.json')).not_to be_nil
expect(@exporter.course[:full_export_file_path].index('spec_canvas/fixtures/qti/qti_qti_2_1/oi/course_export.json')).not_to be_nil
end end
it "should properly detect whether a package is QTI 2.1" do it "should properly detect whether a package is QTI 2.1" do

View File

@ -6,11 +6,10 @@ describe "Converting Blackboard Vista qti" do
before(:all) do before(:all) do
archive_file_path = File.join(BASE_FIXTURE_DIR, 'bb_vista', 'vista_archive.zip') archive_file_path = File.join(BASE_FIXTURE_DIR, 'bb_vista', 'vista_archive.zip')
unzipped_file_path = File.join(File.dirname(archive_file_path), "qti_#{File.basename(archive_file_path, '.zip')}", 'oi') unzipped_file_path = create_temp_dir!
@export_folder = File.join(File.dirname(archive_file_path), "qti_vista_archive") @export_folder = create_temp_dir!
@converter = Qti::Converter.new(:export_archive_path=>archive_file_path, :base_download_dir=>unzipped_file_path, :flavor => Qti::Flavors::WEBCT) @converter = Qti::Converter.new(:export_archive_path=>archive_file_path, :base_download_dir=>unzipped_file_path, :flavor => Qti::Flavors::WEBCT)
@converter.export @converter.export
@converter.delete_unzipped_archive
@assessment = @converter.course[:assessments][:assessments].first @assessment = @converter.course[:assessments][:assessments].first
@questions = @converter.course[:assessment_questions][:assessment_questions] @questions = @converter.course[:assessment_questions][:assessment_questions]
@ -19,13 +18,6 @@ describe "Converting Blackboard Vista qti" do
@course_data['all_files_export']['file_path'] = @course_data['all_files_zip'] @course_data['all_files_export']['file_path'] = @course_data['all_files_zip']
end end
after(:all) do
@converter.delete_unzipped_archive
if File.exist?(@export_folder)
FileUtils::rm_rf(@export_folder)
end
end
def import_into_course def import_into_course
@course = course @course = course
@migration = ContentMigration.create(:context => @course) @migration = ContentMigration.create(:context => @course)

View File

@ -1402,7 +1402,7 @@ end
describe "cc assignment extensions" do describe "cc assignment extensions" do
before(:all) do before(:all) do
archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/cc_assignment_extension.zip") archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/cc_assignment_extension.zip")
unzipped_file_path = Dir.mktmpdir unzipped_file_path = create_temp_dir!
@converter = CC::Importer::Canvas::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) @converter = CC::Importer::Canvas::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
@converter.export @converter.export
@course_data = @converter.course.with_indifferent_access @course_data = @converter.course.with_indifferent_access
@ -1417,7 +1417,6 @@ describe "cc assignment extensions" do
end end
after(:all) do after(:all) do
@converter.delete_unzipped_archive
truncate_all_tables truncate_all_tables
end end
@ -1452,7 +1451,7 @@ describe "matching question reordering" do
before(:all) do before(:all) do
skip unless Qti.qti_enabled? skip unless Qti.qti_enabled?
archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/canvas_matching_reorder.zip") archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/canvas_matching_reorder.zip")
unzipped_file_path = Dir.mktmpdir unzipped_file_path = create_temp_dir!
@converter = CC::Importer::Canvas::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) @converter = CC::Importer::Canvas::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
@converter.export @converter.export
@course_data = @converter.course.with_indifferent_access @course_data = @converter.course.with_indifferent_access
@ -1467,9 +1466,6 @@ describe "matching question reordering" do
end end
after(:all) do after(:all) do
if Qti.qti_enabled?
@converter.delete_unzipped_archive
end
truncate_all_tables truncate_all_tables
end end

View File

@ -7,7 +7,7 @@ describe "Standard Common Cartridge importing" do
context 'in a cartridge' do context 'in a cartridge' do
before(:all) do before(:all) do
archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/asmnt_example.zip") archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/asmnt_example.zip")
unzipped_file_path = Dir.mktmpdir unzipped_file_path = create_temp_dir!
@converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) @converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
@converter.export @converter.export
@course_data = @converter.course.with_indifferent_access @course_data = @converter.course.with_indifferent_access
@ -40,7 +40,7 @@ describe "Standard Common Cartridge importing" do
context 'in a flat file' do context 'in a flat file' do
before(:all) do before(:all) do
archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/flat_imsmanifest.xml") archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/flat_imsmanifest.xml")
unzipped_file_path = Dir.mktmpdir unzipped_file_path = create_temp_dir!
@converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) @converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
@converter.convert @converter.convert
@course_data = @converter.course.with_indifferent_access @course_data = @converter.course.with_indifferent_access
@ -100,7 +100,7 @@ describe "Standard Common Cartridge importing" do
context 'variant support' do context 'variant support' do
before(:all) do before(:all) do
archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/flat_imsmanifest_with_variants.xml") archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/flat_imsmanifest_with_variants.xml")
unzipped_file_path = Dir.mktmpdir unzipped_file_path = create_temp_dir!
@converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) @converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
@converter.convert @converter.convert
@course_data = @converter.course.with_indifferent_access @course_data = @converter.course.with_indifferent_access
@ -146,7 +146,7 @@ describe "Standard Common Cartridge importing" do
before(:all) do before(:all) do
if Qti.qti_enabled? if Qti.qti_enabled?
archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/cc_inline_qti.zip") archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/cc_inline_qti.zip")
unzipped_file_path = Dir.mktmpdir unzipped_file_path = create_temp_dir!
@converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) @converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
@converter.export @converter.export
@course_data = @converter.course.with_indifferent_access @course_data = @converter.course.with_indifferent_access

View File

@ -7,7 +7,7 @@ require 'tmpdir'
describe "Standard Common Cartridge importing" do describe "Standard Common Cartridge importing" do
before(:all) do before(:all) do
archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/cc_full_test.zip") archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/cc_full_test.zip")
unzipped_file_path = Dir.mktmpdir unzipped_file_path = create_temp_dir!
@converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) @converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
@converter.export @converter.export
@course_data = @converter.course.with_indifferent_access @course_data = @converter.course.with_indifferent_access
@ -589,7 +589,7 @@ end
describe "LTI tool combination" do describe "LTI tool combination" do
before(:all) do before(:all) do
archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/cc_lti_combine_test.zip") archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/cc_lti_combine_test.zip")
unzipped_file_path = Dir.mktmpdir unzipped_file_path = create_temp_dir!
@converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) @converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
@converter.export @converter.export
@course_data = @converter.course.with_indifferent_access @course_data = @converter.course.with_indifferent_access
@ -633,7 +633,7 @@ end
describe "cc assignment extensions" do describe "cc assignment extensions" do
before(:all) do before(:all) do
archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/cc_assignment_extension.zip") archive_file_path = File.join(File.dirname(__FILE__) + "/../../../fixtures/migration/cc_assignment_extension.zip")
unzipped_file_path = Dir.mktmpdir unzipped_file_path = create_temp_dir!
@converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) @converter = CC::Importer::Standard::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
@converter.export @converter.export
@course_data = @converter.course.with_indifferent_access @course_data = @converter.course.with_indifferent_access

View File

@ -22,6 +22,7 @@ rescue LoadError
end end
require 'securerandom' require 'securerandom'
require 'tmpdir'
require 'lti_spec_helper.rb' require 'lti_spec_helper.rb'
RSpec.configure do |c| RSpec.configure do |c|
@ -291,6 +292,15 @@ def ensure_group_cleanup!(group)
end end
end end
def cleanup_temp_dirs!
if $temp_dirs
$temp_dirs.each do |dir|
FileUtils::rm_rf(dir) if File.exist?(dir)
end
$temp_dirs = []
end
end
# Be sure to actually test serializing things to non-existent caches, # Be sure to actually test serializing things to non-existent caches,
# but give Mocks a pass, since they won't exist in dev/prod # but give Mocks a pass, since they won't exist in dev/prod
Mocha::Mock.class_eval do Mocha::Mock.class_eval do
@ -407,6 +417,7 @@ RSpec.configure do |config|
end end
config.after :all do |group| config.after :all do |group|
cleanup_temp_dirs!
ensure_group_cleanup!(group) if ENV['ENSURE_GROUP_CLEANUP'] ensure_group_cleanup!(group) if ENV['ENSURE_GROUP_CLEANUP']
end end
@ -601,6 +612,13 @@ RSpec.configure do |config|
update_with_protected_attributes!(ar_instance, attrs) rescue false update_with_protected_attributes!(ar_instance, attrs) rescue false
end end
def create_temp_dir!
dir = Dir.mktmpdir
$temp_dirs ||= []
$temp_dirs << dir
dir
end
def process_csv_data(*lines) def process_csv_data(*lines)
opts = lines.extract_options! opts = lines.extract_options!
opts.reverse_merge!(allow_printing: false) opts.reverse_merge!(allow_printing: false)