diff --git a/app/models/enrollment.rb b/app/models/enrollment.rb index 82871da52d64..9f6c663438a8 100644 --- a/app/models/enrollment.rb +++ b/app/models/enrollment.rb @@ -492,6 +492,7 @@ def update_from(other, skip_broadcasts = false) self.root_account_id = other.root_account_id self.sis_batch_id = other.sis_batch_id unless sis_batch_id.nil? self.skip_touch_user = other.skip_touch_user + self.limit_privileges_to_course_section = other.limit_privileges_to_course_section if skip_broadcasts save_without_broadcasting! else diff --git a/spec/models/course_spec.rb b/spec/models/course_spec.rb index 12b7ef33319b..610677c3ade6 100644 --- a/spec/models/course_spec.rb +++ b/spec/models/course_spec.rb @@ -1851,6 +1851,17 @@ def make_date_completed expect(@course.course_section_visibility(limited_teacher)).to eq [@section2.id] end + it "correctly limits visibilities for a limited teacher observing a student in different section" do + limited_teacher = user_with_pseudonym(name: "Limited Teacher") + @course.enroll_teacher(limited_teacher, + limit_privileges_to_course_section: true, + section: @section2) + student = user_with_pseudonym + @course.enroll_student(student, enrollment_state: "active", section: @section1, limit_privileges_to_course_section: true) + add_linked_observer(student, limited_teacher) + expect(@course.course_section_visibility(limited_teacher)).to eq [@section1.id, @section2.id] + end + it "unlimited teachers can see everything" do unlimited_teacher = User.create(name: "Unlimited Teacher") @course.enroll_teacher(unlimited_teacher, section: @section2)