Skip to content

Commit fcb2506

Browse files
committed
sort by content if no course modules exist
closes CNVS-23800 test plan - export a course with no modules - create an ePub, which would normally result in module sorting by default - the generated ePub should be sorted by content Change-Id: I2e49b7cffd4c3f4bef12357c24814a0c0f837c9d Reviewed-on: https://gerrit.instructure.com/64665 QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Product-Review: Cosme Salazar <cosme@instructure.com> Tested-by: Jenkins Reviewed-by: John Corrigan <jcorrigan@instructure.com>
1 parent 75a6931 commit fcb2506

4 files changed

Lines changed: 23 additions & 2 deletions

File tree

lib/cc/exporter/epub/exporter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Exporter
1919

2020
def initialize(cartridge, sort_by_content=false)
2121
@cartridge = cartridge
22-
@sort_by_content = sort_by_content
22+
@sort_by_content = sort_by_content || cartridge_json[:modules].empty?
2323
end
2424
attr_reader :cartridge, :sort_by_content
2525

20.9 KB
Binary file not shown.
19.1 KB
Binary file not shown.

spec/lib/cc/exporter/epub/exporter_spec.rb

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@
66

77
before(:once) do
88
def cartridge_path
9-
File.join(File.dirname(__FILE__), "/../../../../fixtures/migration/unicode-filename-test-export.imscc")
9+
File.join(File.dirname(__FILE__), "/../../../../fixtures/exporter/cc-with-modules-export.imscc")
10+
end
11+
12+
def cartridge_without_modules_path
13+
File.join(File.dirname(__FILE__), "/../../../../fixtures/exporter/cc-without-modules-export.imscc")
1014
end
1115

1216
@attachment = Attachment.create({
1317
context: course,
1418
filename: 'exortable-test-file',
1519
uploaded_data: File.open(cartridge_path)
1620
})
21+
22+
@attachment_without_modules = Attachment.create({
23+
context: course,
24+
filename: 'exortable-test-file',
25+
uploaded_data: File.open(cartridge_without_modules_path)
26+
})
27+
1728
end
1829

1930
context "create ePub default settings" do
@@ -30,6 +41,16 @@ def cartridge_path
3041
end
3142
end
3243

44+
context "default settings with no modules present" do
45+
let(:exporter) do
46+
CC::Exporter::Epub::Exporter.new(@attachment_without_modules.open)
47+
end
48+
49+
it "should fall back to sorting by content type" do
50+
expect(exporter.templates.key?(:modules)).to be_falsey
51+
end
52+
end
53+
3354
context "create ePub with content type sorting" do
3455
let(:exporter) do
3556
CC::Exporter::Epub::Exporter.new(@attachment.open, true)

0 commit comments

Comments
 (0)