master courses: fix sync when old associations are deleted

Change-Id: Ice68bbb549ef745730bd2bc05146567c4b412b9a
Reviewed-on: https://gerrit.instructure.com/112440
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
James Williams 2017-05-19 10:46:48 -06:00
parent 6a4e784148
commit 1286599425
2 changed files with 17 additions and 1 deletions

View File

@ -118,6 +118,7 @@ class MasterCourses::MasterMigration < ActiveRecord::Base
end
def export_to_child_courses(type, subscriptions, export_is_primary)
@export_type = type
if type == :selective
@deletions = self.master_template.deletions_since_last_export
@creations = {} # will be populated during export
@ -177,7 +178,7 @@ class MasterCourses::MasterMigration < ActiveRecord::Base
end
def add_exported_asset(asset)
return unless last_export_at
return unless @export_type == :selective
@export_count += 1
return if @export_count > Setting.get('master_courses_history_count', '150').to_i
set = asset.created_at >= last_export_at ? @creations : @updates

View File

@ -726,6 +726,21 @@ describe MasterCourses::MasterMigration do
[topic_override, normal_override].each { |ao| expect(ao.reload).to be_deleted }
end
it "should work with a single full export for a new association" do
@copy_to1 = course_factory
sub1 = @template.add_child_course!(@copy_to1)
topic = @copy_from.discussion_topics.create!(:title => "some title")
run_master_migration
sub1.destroy!
@copy_to2 = course_factory
@template.add_child_course!(@copy_to2)
run_master_migration
expect(@copy_to2.discussion_topics.first).to be_present
end
context "master courses + external migrations" do
class TestExternalContentService
cattr_reader :course, :imported_content