export an empty zip
closes OFFW-37 test plan: - it should export an empty zip file (the other parts of this aren't wired up yet, so good luck getting to this) Change-Id: Ied37e879a274c423c3393659e8557f69c7a0cc82 Reviewed-on: https://gerrit.instructure.com/96555 Tested-by: Jenkins Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com> QA-Review: Nathan Rogowski <nathan@instructure.com> Product-Review: Cameron Sutter <csutter@instructure.com>
This commit is contained in:
parent
4dbbe759a7
commit
670740ac69
|
@ -0,0 +1,15 @@
|
||||||
|
module CC::Exporter::WebZip
|
||||||
|
module Exportable
|
||||||
|
def content_cartridge
|
||||||
|
self.attachment
|
||||||
|
end
|
||||||
|
|
||||||
|
def convert_to_offline_web_zip
|
||||||
|
exporter = CC::Exporter::WebZip::Exporter.new(content_cartridge.open, false)
|
||||||
|
zip = CC::Exporter::WebZip::ZipPackage.new(exporter)
|
||||||
|
result = zip.create
|
||||||
|
exporter.cleanup_files
|
||||||
|
result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
module CC::Exporter::WebZip
|
||||||
|
class Exporter < CC::Exporter::Epub::Exporter
|
||||||
|
|
||||||
|
# override epub exporter templates
|
||||||
|
def templates
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
module CC::Exporter::WebZip
|
||||||
|
class ZipPackage < CC::Exporter::Epub::FilesDirectory
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,48 @@
|
||||||
|
# coding: utf-8
|
||||||
|
require File.expand_path(File.dirname(__FILE__) + '/../../cc_spec_helper')
|
||||||
|
|
||||||
|
describe "Exportable" do
|
||||||
|
class ExportableTest
|
||||||
|
include CC::Exporter::WebZip::Exportable
|
||||||
|
|
||||||
|
def attachment
|
||||||
|
@_attachment ||= Attachment.create({
|
||||||
|
context: Course.create,
|
||||||
|
filename: 'exportable-test-file',
|
||||||
|
uploaded_data: File.open(cartridge_path)
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
def cartridge_path
|
||||||
|
File.join(File.dirname(__FILE__), "/../../../../fixtures/migration/unicode-filename-test-export.imscc")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "#convert_to_epub" do
|
||||||
|
|
||||||
|
before do
|
||||||
|
@epub_export = ExportableTest.new.convert_to_offline_web_zip
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:zip_path) do
|
||||||
|
@epub_export
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:zip) do
|
||||||
|
File.open(zip_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should create a zip file" do
|
||||||
|
expect(zip).not_to be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it "creates a zip file whose name includes the cartridge's name" do
|
||||||
|
expect(zip_path).to include('unicode-filename-test')
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
File.delete(zip_path) if File.exist?(zip_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,29 @@
|
||||||
|
# coding: utf-8
|
||||||
|
require File.expand_path(File.dirname(__FILE__) + '/../../cc_spec_helper')
|
||||||
|
|
||||||
|
describe "Exporter" do
|
||||||
|
include CC::Exporter::WebZip
|
||||||
|
|
||||||
|
before(:once) do
|
||||||
|
def cartridge_path
|
||||||
|
File.join(File.dirname(__FILE__), "/../../../../fixtures/exporter/cc-with-modules-export.imscc")
|
||||||
|
end
|
||||||
|
|
||||||
|
@attachment = Attachment.create({
|
||||||
|
context: course,
|
||||||
|
filename: 'exportable-test-file',
|
||||||
|
uploaded_data: File.open(cartridge_path)
|
||||||
|
})
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "create web zip package default settings" do
|
||||||
|
let(:exporter) do
|
||||||
|
CC::Exporter::WebZip::Exporter.new(@attachment.open)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should sort content by module" do
|
||||||
|
expect(exporter.base_template).to eq "../templates/module_sorting_template.html.erb"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue