Skip to content

Commit c18188a

Browse files
committed
don't copy announcements if all_discussion_topics are selected
test plan: * create a course with an announcment and discussion topic * copy the course (with selected content), unchecking the 'Announcements' box * should not import the announcement fixes #CNVS-7285 Change-Id: I22e0f52df5f1af7a5532b143396ea40e86b3f1d1 Reviewed-on: https://gerrit.instructure.com/22935 Reviewed-by: Bracken Mosbacker <bracken@instructure.com> Product-Review: Bracken Mosbacker <bracken@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: August Thornton <august@instructure.com>
1 parent 50c4a73 commit c18188a

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

lib/cc/topic_resources.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ module TopicResources
2020

2121
def add_topics
2222
@course.discussion_topics.active.each do |topic|
23-
next unless export_object?(topic) || export_object?(topic.assignment) || (topic.is_announcement && export_object?(topic, 'announcements'))
23+
if topic.is_announcement
24+
next unless export_object?(topic, 'announcements')
25+
else
26+
next unless export_object?(topic) || export_object?(topic.assignment)
27+
end
2428

2529
title = topic.title rescue I18n.t('course_exports.unknown_titles.topic', "Unknown topic")
2630

spec/lib/cc/cc_exporter_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ def check_resource_node(obj, type, selected=true)
108108

109109
# only select one of each type
110110
@ce.selected_content = {
111-
:discussion_topics => {mig_id(@dt1) => "1", mig_id(@dt3) => "1"},
111+
:discussion_topics => {mig_id(@dt1) => "1"},
112+
:announcements => {mig_id(@dt3) => "1"},
112113
:context_external_tools => {mig_id(@et) => "1"},
113114
:quizzes => {mig_id(@q1) => "1"},
114115
:learning_outcomes => {mig_id(@lo) => "1"},

spec/models/content_migration_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ def mig_id(obj)
399399

400400
# only select one of each type
401401
@cm.copy_options = {
402-
:discussion_topics => {mig_id(dt1) => "1", mig_id(dt3) => "1"},
402+
:discussion_topics => {mig_id(dt1) => "1"},
403+
:announcements => {mig_id(dt3) => "1"},
403404
:context_modules => {mig_id(cm) => "1", mig_id(cm2) => "0"},
404405
:attachments => {mig_id(att) => "1", mig_id(att2) => "0"},
405406
:wiki_pages => {mig_id(wiki) => "1", mig_id(wiki2) => "0"},
@@ -926,6 +927,19 @@ def create_outcome(context, group=nil)
926927
@copy_to.announcements.find_by_migration_id(mig_id(ann)).should_not be_nil
927928
end
928929

930+
it "should not copy announcements if not selected" do
931+
ann = @copy_from.announcements.create!(:message => "howdy", :title => "announcement title")
932+
933+
@cm.copy_options = {
934+
:all_discussion_topics => "1", :all_announcements => "0"
935+
}
936+
@cm.save!
937+
938+
run_course_copy
939+
940+
@copy_to.announcements.find_by_migration_id(mig_id(ann)).should be_nil
941+
end
942+
929943
it "should not copy deleted assignment attached to topic" do
930944
topic = @copy_from.discussion_topics.build(:title => "topic")
931945
assignment = @copy_from.assignments.build(:submission_types => 'discussion_topic', :title => topic.title)

0 commit comments

Comments
 (0)