make courses#workflow_state sis sticky fixes #8258

test plan:
 * import a course via SIS
 * publish and conclude the course via the UI
 * re-import the course via SIS (still 'active') status
 * the course should stay concluded

Change-Id: Ieba993d1aac65a3e0872edec5deda2731f70e165
Reviewed-on: https://gerrit.instructure.com/10422
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
This commit is contained in:
Cody Cutrer 2012-04-30 12:59:40 -06:00
parent 0ec3ed5553
commit 393ba3a317
4 changed files with 32 additions and 12 deletions

View File

@ -181,7 +181,7 @@ class Course < ActiveRecord::Base
sanitize_field :syllabus_body, Instructure::SanitizeField::SANITIZE
include StickySisFields
are_sis_sticky :name, :course_code, :start_at, :conclude_at, :restrict_enrollments_to_course_dates, :enrollment_term_id
are_sis_sticky :name, :course_code, :start_at, :conclude_at, :restrict_enrollments_to_course_dates, :enrollment_term_id, :workflow_state
has_a_broadcast_policy

View File

@ -81,16 +81,18 @@ module SIS
update_account_associations = course.account_id_changed? || course.root_account_id_changed?
course.sis_source_id = course_id
if status =~ /active/i
if course.workflow_state == 'completed'
course.workflow_state = 'available'
elsif course.workflow_state != 'available'
course.workflow_state = 'claimed'
if !course.stuck_sis_fields.include?(:workflow_state)
if status =~ /active/i
if course.workflow_state == 'completed'
course.workflow_state = 'available'
elsif course.workflow_state != 'available'
course.workflow_state = 'claimed'
end
elsif status =~ /deleted/i
course.workflow_state = 'deleted'
elsif status =~ /completed/i
course.workflow_state = 'completed'
end
elsif status =~ /deleted/i
course.workflow_state = 'deleted'
elsif status =~ /completed/i
course.workflow_state = 'completed'
end
course_dates_stuck = !(course.stuck_sis_fields & [:start_at, :conclude_at, :restrict_enrollments_to_course_dates]).empty?

View File

@ -498,4 +498,22 @@ describe SIS::CSV::CourseImporter do
Course.find_by_sis_source_id("test_1").associated_accounts.map(&:id).sort.should == [Account.find_by_sis_source_id('A001').id, @account.id].sort
end
end
it "should make workflow_state sticky" do
process_csv_data_cleanly(
"course_id,short_name,long_name,account_id,term_id,status",
"test_1,TC 101,Test Course 101,,,active"
)
course = Course.find_by_sis_source_id("test_1")
course.should be_claimed
course.process_event('offer')
course.complete
course.should be_completed
process_csv_data_cleanly(
"course_id,short_name,long_name,account_id,term_id,status",
"test_1,TC 101,Test Course 101,,,active"
)
course.reload
course.should be_completed
end
end

View File

@ -205,7 +205,7 @@ describe Course do
@new_course = @course.reset_content
@course.reload
@course.stuck_sis_fields.should == [].to_set
@course.stuck_sis_fields.should == [:workflow_state].to_set
@course.course_sections.should be_empty
@course.students.should be_empty
@course.sis_source_id.should be_nil
@ -239,7 +239,7 @@ describe Course do
@new_course = @course.reset_content
@course.reload
@course.stuck_sis_fields.should == [:name].to_set
@course.stuck_sis_fields.should == [:workflow_state, :name].to_set
@course.sis_source_id.should be_nil
@new_course.reload