add unpublished module items as organization items on export

unpublished items weren't showing up in the common cartridge
organization. (but they were in the custom module xml)

Test Plan:
 * Export a course with some module items that are unpublished
 * there should be an item in the export manifest correlating to that item

closes CNVS-15359

Change-Id: I2763d8f8e3e433ca079fe9a77e2457022428345e
Reviewed-on: https://gerrit.instructure.com/40822
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
This commit is contained in:
Bracken Mosbacker 2014-09-09 15:03:23 -06:00
parent 93631a703c
commit 3f21967641
2 changed files with 28 additions and 1 deletions

View File

@ -52,7 +52,7 @@ module CC
def add_module(cm) def add_module(cm)
@root_item.item(:identifier=>CCHelper.create_key(cm)) do |module_node| @root_item.item(:identifier=>CCHelper.create_key(cm)) do |module_node|
module_node.title cm.name 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)} attributes = {:identifier=>CCHelper.create_key(ct)}
unless ct.content_type == 'ContextModuleSubHeader' unless ct.content_type == 'ContextModuleSubHeader'
attributes[:identifierref] = CCHelper.create_key(ct.content) attributes[:identifierref] = CCHelper.create_key(ct.content)

View File

@ -471,5 +471,32 @@ describe "Common Cartridge exporting" do
html_file = variant_tag.next_element.attribute('href').value html_file = variant_tag.next_element.attribute('href').value
@zip_file.read("#{assignment_id}/test-assignment.html").should be_include "<em>what?</em>" @zip_file.read("#{assignment_id}/test-assignment.html").should be_include "<em>what?</em>"
end 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
end end