make sure to get the right section on sis import

Change-Id: Ie08fbaea4babc960bdb3a859b14282eaaf4b27b9
Reviewed-on: https://gerrit.instructure.com/2887
Reviewed-by: Brian Whitmer <brian@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
Zach Wily 2011-03-30 12:25:24 -06:00
parent 52ce635619
commit dc0d205b89
2 changed files with 24 additions and 3 deletions

View File

@ -41,8 +41,8 @@ module SIS
update_progress
pseudo = Pseudonym.find_by_account_id_and_sis_user_id(@root_account.id, row['user_id'])
user = pseudo.user rescue nil
course = Course.find_by_root_account_id_and_sis_source_id(@root_account.id, row['course_id'])
section = CourseSection.find_by_root_account_id_and_sis_source_id(@root_account.id, row['section_id'])
course = Course.find_by_root_account_id_and_sis_source_id(@root_account.id, row['course_id']) unless row['course_id'].blank?
section = CourseSection.find_by_root_account_id_and_sis_source_id(@root_account.id, row['section_id']) unless row['section_id'].blank?
unless user && (course || section)
add_warning csv, "Neither course #{row['course_id']} nor section #{row['section_id']} existed for user enrollment" unless (course || section)
add_warning csv, "User #{row['user_id']} didn't exist for user enrollment" unless user

View File

@ -365,7 +365,28 @@ describe SIS::SisCsv do
course.designers.first.name.should == "User Cinco"
end
it "should not try looking up a section to enroll into if the section name is empty" do
process_csv_data(
"course_id,short_name,long_name,account_id,term_id,status",
"test_1,TC 101,Test Course 101,,,active",
"test_2,TC 102,Test Course 102,,,active"
)
bad_course = @account.courses.find_by_sis_source_id("test_1")
bad_course.course_sections.length.should == 1
good_course = @account.courses.find_by_sis_source_id("test_2")
good_course.course_sections.length.should == 1
process_csv_data(
"user_id,login_id,first_name,last_name,email,status",
"user_1,user1,User,Uno,user@example.com,active"
)
importer = process_csv_data(
"course_id,user_id,role,section_id,status,associated_user_id",
"test_2,user_1,teacher,,active,"
)
importer.warnings.length.should == 0
importer.errors.length.should == 0
good_course.teachers.first.name.should == "User Uno"
end
end
context 'account importing' do