don't remove dates on blueprint sync without settings

test plan:
* have a blueprint course and an associated course
* set start and end dates on the associated course
* make a sync from the blueprint without settings
 checked
* it should leave the dates alone

* remove the dates on the blueprint course
* make a sync with settings checked
* it should remove the dates on the associated course

closes #ADMIN-1328

Change-Id: I09fbd02da0ef518f363d40fc3c8bfac9bb1d7580
Reviewed-on: https://gerrit.instructure.com/160696
Tested-by: Jenkins
Reviewed-by: Mysti Sadler <mysti@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
James Williams 2018-08-14 06:58:50 -06:00
parent e301c62e16
commit 3ce7e917ef
4 changed files with 17 additions and 6 deletions

View File

@ -345,9 +345,9 @@ module Importers
end
if migration.for_master_course_import?
course.restrict_enrollments_to_course_dates = settings['restrict_enrollments_to_course_dates']
course.start_at = Canvas::Migration::MigratorHelper.get_utc_time_from_timestamp(settings['start_at'])
course.conclude_at = Canvas::Migration::MigratorHelper.get_utc_time_from_timestamp(settings['conclude_at'])
course.restrict_enrollments_to_course_dates = settings['restrict_enrollments_to_course_dates'] if settings.has_key?('restrict_enrollments_to_course_dates')
course.start_at = Canvas::Migration::MigratorHelper.get_utc_time_from_timestamp(settings['start_at']) if settings.has_key?('start_at')
course.conclude_at = Canvas::Migration::MigratorHelper.get_utc_time_from_timestamp(settings['conclude_at']) if settings.has_key?('conclude_at')
end
settings.slice(*atts.map(&:to_s)).each do |key, val|

View File

@ -129,8 +129,8 @@ JOKE
) do |c|
c.title @course.name
c.course_code @course.course_code
c.start_at ims_datetime(@course.start_at) if @course.start_at
c.conclude_at ims_datetime(@course.conclude_at) if @course.conclude_at
c.start_at ims_datetime(@course.start_at, nil)
c.conclude_at ims_datetime(@course.conclude_at, nil)
if @course.tab_configuration.present?
tab_config = []
@course.tab_configuration.each do |t|

View File

@ -74,7 +74,7 @@ module CC::Importer::Canvas
end
['start_at', 'conclude_at'].each do |date_type|
val = get_time_val(doc, date_type)
course[date_type] = val unless val.nil?
course[date_type] = val
end
['grading_standard_id', 'home_page_announcement_limit'].each do |int_val|
if val = get_int_val(doc, int_val)

View File

@ -1096,6 +1096,17 @@ describe MasterCourses::MasterMigration do
expect(@copy_to.start_at).to eq @copy_from.start_at
expect(@copy_to.conclude_at).to eq @copy_from.conclude_at
expect(@copy_to.restrict_enrollments_to_course_dates).to be_truthy
run_master_migration # selective without settings
expect(@copy_to.reload.start_at).to_not be_nil # keep the dates
expect(@copy_to.conclude_at).to_not be_nil
Timecop.freeze(1.minute.from_now) do
@copy_from.update_attributes(:start_at => nil, :conclude_at => nil)
end
run_master_migration(:copy_settings => true) # selective with settings
expect(@copy_to.reload.start_at).to be_nil # remove the dates
expect(@copy_to.conclude_at).to be_nil
end
it "should copy front wiki pages" do