master courses: fix outcome copying on selective export
test plan: * have a blueprint course with an associated course * add an outcome to the blueprint course * it should copy over to the associated course closes #MC-290 Change-Id: I7baf402be34541db55bc7291b6ad8d1d5c85aae6 Reviewed-on: https://gerrit.instructure.com/125039 Tested-by: Jenkins Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com> QA-Review: Heath Hales <hhales@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
b0be6e0175
commit
5059ced17e
|
@ -71,6 +71,7 @@ module Importers
|
|||
root_outcome_group.adopt_outcome_group(item)
|
||||
end
|
||||
|
||||
item.skip_parent_group_touch = true
|
||||
migration.add_imported_item(item)
|
||||
|
||||
if hash[:outcomes]
|
||||
|
|
|
@ -46,6 +46,12 @@ class LearningOutcomeGroup < ActiveRecord::Base
|
|||
[learning_outcome_group_id]
|
||||
end
|
||||
|
||||
def touch_parent_group
|
||||
return if self.skip_parent_group_touch
|
||||
self.touch
|
||||
self.learning_outcome_group.touch_parent_group if self.learning_outcome_group
|
||||
end
|
||||
|
||||
# adds a new link to an outcome to this group. does nothing if a link already
|
||||
# exists (an outcome can be linked into a context multiple times by multiple
|
||||
# groups, but only once per group).
|
||||
|
@ -55,6 +61,7 @@ class LearningOutcomeGroup < ActiveRecord::Base
|
|||
return outcome_link if outcome_link
|
||||
|
||||
# create new link and in this group
|
||||
touch_parent_group
|
||||
child_outcome_links.create(
|
||||
:content => outcome,
|
||||
:context => self.context || self)
|
||||
|
@ -87,6 +94,7 @@ class LearningOutcomeGroup < ActiveRecord::Base
|
|||
copy.add_outcome(link.content)
|
||||
end
|
||||
|
||||
touch_parent_group
|
||||
# done
|
||||
copy
|
||||
end
|
||||
|
@ -101,6 +109,7 @@ class LearningOutcomeGroup < ActiveRecord::Base
|
|||
# change the parent
|
||||
outcome_link.associated_asset = self
|
||||
outcome_link.save!
|
||||
touch_parent_group
|
||||
outcome_link
|
||||
end
|
||||
|
||||
|
@ -120,7 +129,7 @@ class LearningOutcomeGroup < ActiveRecord::Base
|
|||
group
|
||||
end
|
||||
|
||||
attr_accessor :skip_tag_touch
|
||||
attr_accessor :skip_tag_touch, :skip_parent_group_touch
|
||||
alias_method :destroy_permanently!, :destroy
|
||||
def destroy
|
||||
transaction do
|
||||
|
|
|
@ -178,7 +178,7 @@ class MasterCourses::MasterMigration < ActiveRecord::Base
|
|||
|
||||
def export_object?(obj)
|
||||
return false unless obj
|
||||
last_export_at.nil? || obj.updated_at >= last_export_at
|
||||
last_export_at.nil? || obj.updated_at.nil? || obj.updated_at >= last_export_at
|
||||
end
|
||||
|
||||
def detect_updated_attachments(type)
|
||||
|
|
|
@ -53,6 +53,8 @@ module Api::V1::MasterCourses
|
|||
asset.display_name
|
||||
elsif asset.respond_to?(:title)
|
||||
asset.title
|
||||
elsif asset.respond_to?(:short_description)
|
||||
asset.short_description
|
||||
else
|
||||
asset.name
|
||||
end
|
||||
|
|
|
@ -958,6 +958,30 @@ describe MasterCourses::MasterMigration do
|
|||
expect(tag.reload).to_not be_deleted
|
||||
end
|
||||
|
||||
it "should copy outcomes in selective copies" do
|
||||
@copy_to = course_factory
|
||||
sub = @template.add_child_course!(@copy_to)
|
||||
|
||||
default = @copy_from.root_outcome_group
|
||||
log = @copy_from.learning_outcome_groups.create!(:context => @copy_from, :title => "outcome groupd")
|
||||
default.adopt_outcome_group(log)
|
||||
|
||||
run_master_migration # get the full sync out of the way
|
||||
|
||||
Timecop.freeze(1.minute.from_now) do
|
||||
@lo = @copy_from.created_learning_outcomes.new(:context => @copy_from, :short_description => "whee", :workflow_state => 'active')
|
||||
@lo.data = {:rubric_criterion=>{:mastery_points=>2, :ratings=>[{:description=>"e", :points=>50}, {:description=>"me", :points=>2},
|
||||
{:description=>"Does Not Meet Expectations", :points=>0.5}], :description=>"First outcome", :points_possible=>5}}
|
||||
@lo.save!
|
||||
log.reload.add_outcome(@lo)
|
||||
end
|
||||
|
||||
run_master_migration
|
||||
expect(@migration).to be_completed
|
||||
lo_to = @copy_to.learning_outcomes.where(:migration_id => mig_id(@lo)).first
|
||||
expect(lo_to).to be_present
|
||||
end
|
||||
|
||||
it "sends notifications", priority: "2", test_id: 3211103 do
|
||||
n0 = Notification.create(:name => "Blueprint Sync Complete")
|
||||
n1 = Notification.create(:name => "Blueprint Content Added")
|
||||
|
|
Loading…
Reference in New Issue