diff --git a/lib/cc/organization.rb b/lib/cc/organization.rb index 46e0130f04c..1204301e7e1 100644 --- a/lib/cc/organization.rb +++ b/lib/cc/organization.rb @@ -52,7 +52,7 @@ module CC def add_module(cm) @root_item.item(:identifier=>CCHelper.create_key(cm)) do |module_node| module_node.title cm.name - cm.content_tags.active.each do |ct| + cm.content_tags.not_deleted.each do |ct| attributes = {:identifier=>CCHelper.create_key(ct)} unless ct.content_type == 'ContextModuleSubHeader' attributes[:identifierref] = CCHelper.create_key(ct.content) diff --git a/spec/lib/cc/cc_exporter_spec.rb b/spec/lib/cc/cc_exporter_spec.rb index a169110bb89..6331346adaa 100644 --- a/spec/lib/cc/cc_exporter_spec.rb +++ b/spec/lib/cc/cc_exporter_spec.rb @@ -471,5 +471,32 @@ describe "Common Cartridge exporting" do html_file = variant_tag.next_element.attribute('href').value @zip_file.read("#{assignment_id}/test-assignment.html").should be_include "what?" end + + it "should export unpublished modules and items" do + cm1 = @course.context_modules.create!(name: "published module") + cm1.publish + cm2 = @course.context_modules.create!(name: "unpublished module") + cm2.unpublish + + tag1_1 = cm1.add_item(type: 'external_url', title: 'unpub url', url: 'https://example.com') + tag1_1.workflow_state = 'unpublished' + tag1_1.save! + tag1_2 = cm1.add_item(type: 'external_url', title: 'pub url', url: 'https://example.com') + tag1_2.workflow_state = 'published' + tag1_2.save! + + tag2_1 = cm2.add_item(type: 'external_url', title: 'unpub url 2', url: 'https://example.com') + tag2_1.workflow_state = 'unpublished' + tag2_1.save! + + @ce.export_type = ContentExport::COMMON_CARTRIDGE + @ce.save! + run_export + + @manifest_doc.at_css("item[identifier=#{mig_id(tag1_1)}]").should_not be_nil + @manifest_doc.at_css("item[identifier=#{mig_id(tag1_2)}]").should_not be_nil + @manifest_doc.at_css("item[identifier=#{mig_id(tag2_1)}]").should_not be_nil + end + end end